Pelles C forum
Assembly language => Assembly discussions => Topic started by: themaster on May 06, 2012, 11:23:23 AM
-
Recently I found a macro, which allows to define unicode strings in ansi source files. It's original code is on russian-language page here:
http://www.cyberforum.ru/assembler/thread340298.html
But - it use uncompartible macro mnemonics and I can not assemble my source file with this macro.
I found, that irpc is deprecate, and replaced it to 'for'. But - two strings of macro still generates error messages.
Macro code is:
du macro string
local bslash
bslash = 0
for c, <string>
if bslash eq 0
if 0 eq 1 ; string to replace buggy next one;
; if '&c' eq "/" - this string generates error message "Must be a constant integer expression" if uncommented
bslash = 1
elseif 0 gt 127 ; string to replace buggy next one;
; elseif '&c' gt 127 - this string generated the same error message
db ('&c'- 0B0h),4
else
dw '&c'
endif
else
bslash = 0
if '&c' eq "n" ; but - this string is not generating error message!
DW 0Dh,0Ah
elseif '&c' eq "/"
dw '/'
elseif '&c' eq "r"
dw 0Dh
elseif '&c' eq "l"
dw 0Ah
elseif '&c' eq "s"
dw 20h
elseif '&c' eq "c"
dw 3Bh
elseif '&c' eq "t"
dw 9
endif
endif
endm
;dw 0 - this string also generate error message... but - I can add terminating null manually.
endm
Please help to debug this macro, if it is not very difficult?
Source code is attached.
-
Hi themaster,
Welcome to the forum.
You don't need a macro to define UNICODE strings. The dw directive does the job :
.386
.model flat,stdcall
option casemap:none
includelib \PellesC\lib\Win\kernel32.lib
includelib \PellesC\lib\Win\user32.lib
MessageBoxW PROTO :DWORD,:DWORD,:DWORD,:DWORD
ExitProcess PROTO :DWORD
MB_OK equ 0
.data
capt dw 'Hello',0
message dw 'This a UNICODE test',0
.code
start:
invoke MessageBoxW,0,ADDR message,ADDR capt,MB_OK
invoke ExitProcess,0
END start
-
Thanks, it's just what I need.