flat assembler
Message board for the users of flat assembler.

 Index > Macroinstructions > extended display
Author
Joshua

Joined: 12 Jul 2003
Posts: 56
Location: Belgium
Joshua 13 Jul 2003, 07:05
[update]
new macro in next post
[/update]
Code:
```macro display [param]
{ forward
if <param> eq <>
else if param eqtype 0
local n,d1,d2,d3,d4,d5,d6,d7,d8
virtual
dd param
end virtual
d1 = (n and 0Fh) shr 0
d2 = (n and 0FFh) shr 4
d3 = (n and 0FFFh) shr 8
d4 = (n and 0FFFFh) shr 12
d5 = (n and 0FFFFFh) shr 16
d6 = (n and 0FFFFFFh) shr 20
d7 = (n and 0FFFFFFFh) shr 24
d8 = (n and 0FFFFFFFFh) shr 28
if d1 >= 0 & d1 <= 9
d1 = d1 + 48
else if d1 >= 10 & d1 <= 15
d1 = d1 + 55
else
d1 = 0
end if
if d2 >= 0 & d2 <= 9
d2 = d2 + 48
else if d2 >= 10 & d2 <= 15
d2 = d2 + 55
else
d2 = 0
end if
if d3 >= 0 & d3 <= 9
d3 = d3 + 48
else if d3 >= 10 & d3 <= 15
d3 = d3 + 55
else
d3 = 0
end if
if d4 >= 0 & d4 <= 9
d4 = d4 + 48
else if d4 >= 10 & d4 <= 15
d4 = d4 + 55
else
d4 = 0
end if
if d5 >= 0 & d5 <= 9
d5 = d5 + 48
else if d5 >= 10 & d5 <= 15
d5 = d5 + 55
else
d5 = 0
end if
if d6 >= 0 & d6 <= 9
d6 = d6 + 48
else if d6 >= 10 & d6 <= 15
d6 = d6 + 55
else
d6 = 0
end if
if d7 >= 0 & d7 <= 9
d7 = d7 + 48
else if d7 >= 10 & d7 <= 15
d7 = d7 + 55
else
d7 = 0
end if
if d8 >= 0 & d8 <= 9
d8 = d8 + 48
else if d8 >= 10 & d8 <= 15
d8 = d8 + 55
else
d8 = 0
end if
display d8,d7,d6,d5,d4,d3,d2,d1,"h"
else if param eqtype ""
display param
end if
common
display 13,10
}
```

usage
Code:
`display SomeNumber, " + ", SomeNumber, " = ", AnotherNumber    `

Last edited by Joshua on 08 Nov 2003, 10:26; edited 2 times in total
13 Jul 2003, 07:05
Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 8347
Location: Kraków, Poland
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

Joined: 12 Jul 2003
Posts: 56
Location: Belgium
Joshua 02 Nov 2003, 11:38
I updated my display macro:
[new update 08/11/2003]
- 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
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
display ..c
end repeat
end virtual
}

macro TEMP_DISPLAY_INT [number]
{ common
..count = 0
forward
..count = ..count+1
if ..count > 1
display 32
end if
virtual
dd number
end virtual
if ..n = 0
display 48
else
if ..n and 80000000h
display 45
..n = -..n and 0FFFFFFFFh
end if
..shift = 1000000000
..zero = 1
repeat 10
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
..shift = ..shift/10
end repeat
end if
}

macro TEMP_DISPLAY_UINT [number]
{ common
..count = 0
forward
..count = ..count+1
if ..count > 1
display 32
end if
virtual
dd number
end virtual
if ..n = 0
display 48
else
..shift = 1000000000
..zero = 1
repeat 10
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
..shift = ..shift/10
end repeat
end if
}

macro TEMP_DISPLAY_HEX [number]
{ common
..count = 0
forward
..count = ..count+1
if ..count > 1
display 32
end if
virtual
dd number
end virtual
..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
..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
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum