NO

Author Topic: Unicode strings in Assembler - help to debug macro!  (Read 6956 times)

themaster

  • Guest
Unicode strings in Assembler - help to debug macro!
« 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:
Code: [Select]
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.

Offline Vortex

  • Member
  • *
  • Posts: 864
    • http://www.vortex.masmcode.com
Re: Unicode strings in Assembler - help to debug macro!
« Reply #1 on: May 06, 2012, 11:46:28 AM »
Hi themaster,

Welcome to the forum.

You don't need a macro to define UNICODE strings. The dw directive does the job :

Code: [Select]
.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
Code it... That's all...

themaster

  • Guest
Re: Unicode strings in Assembler - help to debug macro!
« Reply #2 on: May 06, 2012, 01:14:39 PM »
Thanks, it's just what I need.