64 bit assembler > ASMC Development

Unicode strings

(1/3) > >>

nidud:
The switch /ws is added to convert "quoted strings" to Unicode. In addition to this the OPTION WSTRING:[ON|OFF] is added. This will allow declaration of a string array directly in the data segment using DW:

--- Code: --- option wstring:on

dw "Declaring a Unicode string",0

--- End code ---

Test case:

--- Code: ---include conio.inc
include ctype.inc

.code

main proc

_cputws( "Type 'Y' when finished typing keys: " )

.repeat

toupper( _getwch()  )

.until al == 'Y'

_putwch( eax ) ; 'Y'
_putwch( 13 ) ; Carriage return
_putwch( 10 ) ; Line feed

xor eax,eax
ret

main endp

END main

--- End code ---

Makefile:

--- Code: ---_getwch.exe:
asmc -ws -pe -D__PE__ -D_WIN64 $*.asm
$@
pause

--- End code ---

This also works with the @CStr() macro.

ragdog:
Nice idea :t

Vortex:
Hi nidud,

Nice work with asmc. Poasm has the same approach, dw is used for words or Unicode strings. Why not to use du looking more specific than dw?

nidud:

--- Quote from: Vortex on January 13, 2017, 07:16:06 AM ---Poasm has the same approach, dw is used for words or Unicode strings. Why not to use du looking more specific than dw?
--- End quote ---

The plan was to rewrite the string parsing for this implementation, only targeting the existing functionality of the string usage. However, I had to create a whole duplicated set of functions for this to work correctly, so it became rather extensive.

Extending the DW functionality on the other hand was rather simple, so I went with the lazy approach: you then only have to flip DB to DW in the end. Given it's possible to define little endian values using DW it does create some compatibility issues, but at the same time also add some extended functionality to the data section.


--- Code: --- dw "ab"

--- End code ---

In addition to this the string-hash used for detecting duplicated strings still uses the original ASCII string, so switching the option on and off may have unintended consequences:

--- Code: --- mov eax,@CStr( "abcdef" )
option wstring:on
mov eax,@CStr( "def" )

--- End code ---

The last one will now use the offset of the first ASCII string + 3.

Well, as for now the only usage is Asmc -ws, so it wont create any potential backward compatibility issues given it will mainly be used writing in this syntax. The implementation in the data segment may change later if this becomes an issue and the DU options may then be a solution.

hutch--:
 :biggrin:

> The switch /ws is added to convert "quoted strings" to Unicode. In addition to this the OPTION WSTRING:[ON|OFF] is added. This will allow declaration of a string array directly in the data segment using DW:

Compliments, this has needed to be done for a long time.  :t

Navigation

[0] Message Index

[#] Next page

Go to full version