flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > extended display |
Author |
|
Tomasz Grysztar 22 Jul 2003, 11:00
You can find other similar extension (with ability to display numbers with any base) here: http://board.flatassembler.net/topic.php?t=86.
|
|||
22 Jul 2003, 11:00 |
|
Joshua 02 Nov 2003, 11:38
I updated my display macro:
[new update 08/11/2003] added string functions: - CHAR - LSTR - RSTR allowed more than one number to be passed to a function ex: display <HEX 1,2,3> [/update] Code: macro display [param] { forward if <param> eq <> else if param eqtype 0 TEMP_DISPLAY_INT param else if param eqtype "" display param else TEMP_DISPLAY_#param end if common display 13,10 } macro TEMP_DISPLAY_CHAR [number] { forward display number } macro TEMP_DISPLAY_LSTR size,[string] { common local ..c,..size virtual at 0 forward if ~<string> eq <> db string end if common ..size = $ if size-..size > 0 repeat size-..size db 32 end repeat end if repeat size load ..c byte from %-1 display ..c end repeat end virtual } macro TEMP_DISPLAY_RSTR size,[string] { common local ..c,..size virtual at 0 common repeat size db 32 end repeat forward if ~<string> eq <> db string end if common ..size = $ repeat size load ..c byte from ..size-size+%-1 display ..c end repeat end virtual } macro TEMP_DISPLAY_INT [number] { common local ..n,..d,..count,..mask,..shift,..zero ..count = 0 forward ..count = ..count+1 if ..count > 1 display 32 end if virtual dd number load ..n dword from $-4 end virtual if ..n = 0 display 48 else if ..n and 80000000h display 45 ..n = -..n and 0FFFFFFFFh end if ..mask = 10000000000 ..shift = 1000000000 ..zero = 1 repeat 10 ..d = (..n mod ..mask)/..shift if ..d = 0 if ~..zero display 48 end if else if ..d >= 1 & ..d <= 9 ..zero = 0 display ..d+48 else display 63 end if ..mask = ..mask/10 ..shift = ..shift/10 end repeat end if } macro TEMP_DISPLAY_UINT [number] { common local ..n,..d,..count,..mask,..shift,..zero ..count = 0 forward ..count = ..count+1 if ..count > 1 display 32 end if virtual dd number load ..n dword from $-4 end virtual if ..n = 0 display 48 else ..mask = 10000000000 ..shift = 1000000000 ..zero = 1 repeat 10 ..d = (..n mod ..mask)/..shift if ..d = 0 if ~..zero display 48 end if else if ..d >= 1 & ..d <= 9 ..zero = 0 display ..d+48 else display 63 end if ..mask = ..mask/10 ..shift = ..shift/10 end repeat end if } macro TEMP_DISPLAY_HEX [number] { common local ..n,..d,..count,..mask,..shift ..count = 0 forward ..count = ..count+1 if ..count > 1 display 32 end if virtual dd number load ..n dword from $-4 end virtual ..mask = 0FFFFFFFFh ..shift = 28 repeat 8 ..d = (..n and ..mask) shr ..shift if ..d >= 0 & ..d <= 9 display ..d+48 else if ..d >= 10 & ..d <= 15 display ..d+55 else display 63 end if ..mask = ..mask shr 4 ..shift = ..shift-4 end repeat display 104 } usage: Code: display "-1 as int: ",-1,\ ", -1 as unsigned int: ",UINT (-1),\ ", -1 as hex: ",HEX (-1),\ ", 65 as char: ",CHAR 65,\ ", 'blah' left aligned by 10: '",<LSTR 10,'blah'>,"'",\ ", 'blah' right aligned by 10: '",<RSTR 10,'blah'>,"'" this should result in: Code: -1 as int: -1, -1 as unsigned int: 4294967295, -1 as hex: FFFFFFFFh, 65 as char: A, 'blah' left aligned by 10: 'blah ', 'blah' right aligned by 10: ' blah' |
|||
02 Nov 2003, 11:38 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.