flat assembler
Message board for the users of flat assembler.
Index
> Main > define sized constant Goto page 1, 2 Next |
Author |
|
revolution 02 Sep 2010, 13:43
Use:
Code: cmp byte[esi],tchar0 Code: tchar0 equ byte 0 |
|||
02 Sep 2010, 13:43 |
|
Tomasz Grysztar 02 Sep 2010, 13:52
Dimas wrote: Hi! |
|||
02 Sep 2010, 13:52 |
|
Dimas 02 Sep 2010, 13:54
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? |
|||
02 Sep 2010, 13:54 |
|
Dimas 02 Sep 2010, 14:20
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? |
|||
02 Sep 2010, 14:20 |
|
Dimas 02 Sep 2010, 15:20
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} |
|||
02 Sep 2010, 15:20 |
|
revolution 02 Sep 2010, 15:29
Dimas wrote: Last question. Why this code don't work for undefined constant: Code: match eUnicode,eUnicode {err} |
|||
02 Sep 2010, 15:29 |
|
Tomasz Grysztar 02 Sep 2010, 15:47
revolution wrote: Use this: Code: match =eUnicode,eUnicode {err} |
|||
02 Sep 2010, 15:47 |
|
Dimas 02 Sep 2010, 15:50
match eUnicode,eUnicode {err}
match TRUE always (then eUnicode defined or undefined). |
|||
02 Sep 2010, 15:50 |
|
Dimas 02 Sep 2010, 15:52
match =eUnicode,eUnicode {err}
Yes!!! |
|||
02 Sep 2010, 15:52 |
|
Dimas 02 Sep 2010, 15:59
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! |
|||
02 Sep 2010, 15:59 |
|
Tomasz Grysztar 02 Sep 2010, 16:06
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.
|
|||
02 Sep 2010, 16:06 |
|
Dimas 02 Sep 2010, 16:11
tchar equ byte
... tchar equ word That's right. |
|||
02 Sep 2010, 16:11 |
|
baldr 02 Sep 2010, 18:06
Tomasz Grysztar wrote:
Code: match 13, 10 { db "Hello, world!", 13, 10 } |
|||
02 Sep 2010, 18:06 |
|
Tomasz Grysztar 02 Sep 2010, 18:11
baldr wrote:
Code: match eUnicode,eUnicode { display 'A' } ; match define eUnicode match eUnicode,eUnicode { display 'B' } ; no match |
|||
02 Sep 2010, 18:11 |
|
baldr 02 Sep 2010, 18:41
Tomasz Grysztar,
I've meant side effect of such match: Code: match a, a { match anything, a \{ db "a defined" \} } |
|||
02 Sep 2010, 18:41 |
|
Tomasz Grysztar 02 Sep 2010, 18:48
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) |
|||
02 Sep 2010, 18:48 |
|
baldr 02 Sep 2010, 19:35
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" \} } |
|||
02 Sep 2010, 19:35 |
|
Tomasz Grysztar 02 Sep 2010, 19:49
baldr wrote:
Or... Code: define c b match b, a { match =\b, c \{ display "matched" \} } |
|||
02 Sep 2010, 19:49 |
|
baldr 03 Sep 2010, 04:51
Tomasz Grysztar,
Almost. I mean that missing '=' can cause subtle errors: Code: match 1, UNICODE { ;... match 1, WIN32 \{ |
|||
03 Sep 2010, 04:51 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.