flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
revolution
Use:
Code: cmp byte[esi],tchar0 Code: tchar0 equ byte 0 |
|||
![]() |
|
Tomasz Grysztar
Dimas wrote: Hi! |
|||
![]() |
|
Dimas
But on Unicode:
cmp word [esi], 0 (or cmp [esi], word 0) if sizeof.TCHAR... like this: macro stosc { if sizeof.TCHAR = 1 stosb else stosw end if } But on size prefics it's not work. Why? |
|||
![]() |
|
Dimas
I wont make code universal for ANSI and Unicode, and include 'win32wx.inc' mast be enough for this. In this case I have numerical constant sizeof.TCHAR.
And this code wrong: if sizeof.TCHAR = 1 tchar equ byte else tchar equ word end if cmp [esi], tchar 0 Good code: if sizeof.TCHAR = 1 cmp [esi], byte 0 else cmp [esi], word 0 end if But size prefics may be present in thousand operands. How make macro for this purpose? |
|||
![]() |
|
Dimas
Main module:
... eUnicode equ TRUE ;selector for Unicode _in one place_ !!! include '..\_macro.asm' ... macro.asm: ... define eUnicode_ 0 match =FALSE, eUnicode { tchar fix byte include 'win32ax.inc' define eUnicode_ 1 } match =TRUE, eUnicode { tchar fix word include 'win32wx.inc' include 'encoding\win1251.inc' define eUnicode_ 1 } match =0, eUnicode_ {display 'Define eUnicode constant' err} ... Thanks to all. Last question. Why this code don't work for undefined constant: match , eUnicode {err} |
|||
![]() |
|
revolution
Dimas wrote: Last question. Why this code don't work for undefined constant: Code: match eUnicode,eUnicode {err} |
|||
![]() |
|
Tomasz Grysztar
revolution wrote: Use this: Code: match =eUnicode,eUnicode {err} |
|||
![]() |
|
Dimas
match eUnicode,eUnicode {err}
match TRUE always (then eUnicode defined or undefined). |
|||
![]() |
|
Dimas
match =eUnicode,eUnicode {err}
Yes!!! |
|||
![]() |
|
Dimas
from the foregoing it follows simple addon in macro.asm
Code: match =FALSE, eUnicode { tchar fix byte include 'win32ax.inc' } match =TRUE, eUnicode { tchar fix word include 'win32wx.inc' include 'encoding\win1251.inc' } match =eUnicode, eUnicode {display 'Define eUnicode constant' err} Thanks! |
|||
![]() |
|
Tomasz Grysztar
That's not the right way to use "fix" - it is interpreted with highest priority (before the actual preprocessing) and therefore is not affected by "match" directive.
|
|||
![]() |
|
Dimas
tchar equ byte
... tchar equ word That's right. |
|||
![]() |
|
baldr
Tomasz Grysztar wrote:
Code: match 13, 10 { db "Hello, world!", 13, 10 } |
|||
![]() |
|
Tomasz Grysztar
baldr wrote:
Code: match eUnicode,eUnicode { display 'A' } ; match define eUnicode match eUnicode,eUnicode { display 'B' } ; no match |
|||
![]() |
|
baldr
Tomasz Grysztar,
I've meant side effect of such match: Code: match a, a { match anything, a \{ db "a defined" \} } |
|||
![]() |
|
Tomasz Grysztar
What side-effect? This nesting seems redundant.
The way of using the trick I mentioned is perhaps better seen when it is written this way: Code: match anything,a { display 'a not defined' } define a match anything,a { display 'a not defined' }; now it is "defined" (that is: empty) |
|||
![]() |
|
baldr
Tomasz Grysztar,
I've understood the trick first time, thanks. My example was bad indeed. Code: define c b match b, a { match =b, c \{ display "matched" \} } ![]() |
|||
![]() |
|
Tomasz Grysztar
baldr wrote:
Or... Code: define c b match b, a { match =\b, c \{ display "matched" \} } ![]() |
|||
![]() |
|
baldr
Tomasz Grysztar,
Almost. I mean that missing '=' can cause subtle errors: Code: match 1, UNICODE { ;... match 1, WIN32 \{ ![]() |
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.