flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > debug var in macro |
Author |
|
emil 24 Feb 2017, 15:52
Hi All
consider the next macro. Code: macro bla var = 10 .... .... end macro how to print the value of var? |
|||
24 Feb 2017, 15:52 |
|
revolution 24 Feb 2017, 16:02
Assuming you mean assembly-time printing then here is one way to do it:
https://board.flatassembler.net/topic.php?t=3979 If that doesn't work for you then there are other solutions posted also. |
|||
24 Feb 2017, 16:02 |
|
emil 24 Feb 2017, 16:15
Oh , sorry , i was asking for famg not fasm1.
|
|||
24 Feb 2017, 16:15 |
|
revolution 24 Feb 2017, 16:22
There are existing solutions posted for fasmg also. Maybe one of them will work for you.
|
|||
24 Feb 2017, 16:22 |
|
emil 24 Feb 2017, 16:28
may you point me to one of them please.
|
|||
24 Feb 2017, 16:28 |
|
Tomasz Grysztar 24 Feb 2017, 16:53
If you just need to quickly peek at a number and decimal representation is enough for you, you can use this simple trick (inherited from fasm's REPT):
Code: var = 10 rept 1, x: var display `x end rept Code: macro disphex? value* local number,digit number = value if number < 0 display '-' number = - number end if repeat 1 + (bsr number shr 2) digit = ((number) shr ((%%-%) shl 2)) and 0Fh if % = 1 & digit > 9 display '0' end if if digit < 10 display '0'+digit else display 'A'+digit-10 end if end repeat display 'h' end macro disphex var And then you could even combine various macros into one able to display various types of values: Code: macro disphex? value* local number,digit number = value if number < 0 display '-' number = - number end if repeat 1 + (bsr number shr 2) digit = ((number) shr ((%%-%) shl 2)) and 0Fh if % = 1 & digit > 9 display '0' end if if digit < 10 display '0'+digit else display 'A'+digit-10 end if end repeat display 'h' end macro macro dispfloat? value*,precision:2 local x,i,pos,sgn,dgt,txt x = value x = x * 1e#precision sgn = 0 if x < 0 x = -x sgn = 1 end if i = trunc x if x - i >= float 1/2 i = i + 1 end if pos = 0 txt = '' while i | pos <= precision dgt = i mod 10 i = i / 10 txt = txt shl 8 + '0' + dgt pos = pos + 1 if pos = precision txt = txt shl 8 + '.' end if end while if sgn txt = txt shl 8 + '-' end if display string txt end macro macro dispx? values& iterate value, values if value eqtype '' display value else if value eqtype 1f dispfloat value else if value eqtype 0 & value relativeto 0 disphex value else err 'unsupported kind of value' end if end iterate display 13,10 end macro ; Usage example: x = 10 y = 3.14 dispx 'x = ',x,' & y = ',y |
|||
24 Feb 2017, 16:53 |
|
emil 24 Feb 2017, 17:04
thanks Tomasz.
is the first one work from inside any macro? |
|||
24 Feb 2017, 17:04 |
|
emil 24 Feb 2017, 17:44
ok , i have test it , and feet my need.
|
|||
24 Feb 2017, 17:44 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.