Author Topic: Unicode strings  (Read 6060 times)

nidud

  • Member
  • *****
  • Posts: 1717
    • https://github.com/nidud/asmc
Re: Unicode strings
« Reply #15 on: March 16, 2019, 01:29:59 AM »
I have done a small test for ASMC Unicode facilities. It is the first time I use ASMC, so a few things are probably not right. But it works!
:t

So lets see.

Code: [Select]
includelib G:\asmc\lib\libc.lib
The include files (suppose to) auto insert includelib or dllimport based on switches used, and the lib-path should be resolved by the linker. The 32-bit path is ./lib and ./lib/amd64 for 64-bit. I suspect in this case the above link directive is ignored by VS.

Code: [Select]
include G:\asmc\include\conio.inc
include G:\asmc\include\ctype.inc
include G:\asmc\include\winnls.inc

This works but there is a switch for that: /IG:\asmc\include

Code: [Select]
;option wstring:on
OPTION CODEPAGE:CP_UTF8

Works, but there is a switch for that too: /ws65001
Note: The /ws switch defines _UNICODE.

Code: [Select]
.const
someRussian dw "ASMC 1 - Встре́ча с медве́дем мо́жет быть о́чень опа́сна.",10,0

I try to avoid this if possible given all strings could (now) be used directly.
It woks but consider this: someRussian equ <L"...">

Code: [Select]
_cputws(offset someRussian)

offset should not be used in invoke. Use ADDR or & instead.

Code: [Select]
_cputws(@CStr( "ASMC 2 - Встре́ча с медве́дем мо́жет быть о́чень опа́сна.\n"));

The invoke directive (the foo(...) version) has a more sophisticated string handling than the @CStr() macro so use this instead:
Code: [Select]
_cputws(L"ASMC 2 - Встре́ча с медве́дем мо́жет быть о́чень опа́сна.\n");

Quote
asmc64.exe /c -win64 -Zp8 /nologo /Zi /Fo”x64\Release\%(FileName).obj” /W2 /coff
ASMC64 can not build 32-bit objects so the -win64 switch is ignored here. The default is 64-bit coff output.

Quote
It is amazing that the same ASMC source code builds both for 32-bit and 64-bit without any change.

This be the reason for the nitpicking here: if you move all the fiddling inside the source outside, this may be possible.

Quote
Even the same libc.lib works both for 32-bit and 64-bit (In other words, why do I need to declare it if it is not needed at all in this program?  :biggrin:).

 :biggrin: Look at your map file.

AW

  • Member
  • *****
  • Posts: 2230
  • Let's Make ASM Great Again!
Re: Unicode strings
« Reply #16 on: March 16, 2019, 03:04:23 AM »
Good explanation  :t