flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Simple listing macro for fasmg Goto page Previous 1, 2 |
Author |
|
Tomasz Grysztar 15 Oct 2017, 15:08
With the new VIRTUAL features it becomes very easy to alter the macros so that they write the listing into a separate file:
Code: Listing? = 1 namespace Listing base = $$ offset = $ virtual at 0 HexDigits:: db '0123456789ABCDEF' end virtual virtual as 'lst' Text:: end virtual end namespace macro ? line& line rmatch =nolist?, line Listing? =: 0 else rmatch =list?, line restore Listing? else if Listing namespace Listing if ~ $$ eq base base = $$ offset = $$ end if bytes = $ - offset if $ - bytes < $$ bytes = $ - $$ end if offset = $ address = (offset scale 0)-bytes virtual Text repeat 8 load digit:byte from HexDigits:((address) shr ((%%-%) shl 2)) and 0Fh db digit end repeat db ': ' end virtual if bytes < 0 bytes = 0 end if while bytes > 0 if bytes > 8 bytes_in_row = 8 else bytes_in_row = bytes end if if $ - bytes + bytes_in_row <= $@ readable_bytes = bytes_in_row else if $ - bytes >= $@ readable_bytes = 0 else readable_bytes = bytes_in_row - ($ - $@) end if load data:readable_bytes from $ - bytes virtual Text repeat readable_bytes load digit:byte from HexDigits:(data shr ((%-1) shl 3 + 4)) and 0Fh db digit load digit:byte from HexDigits:(data shr ((%-1) shl 3)) and 0Fh db digit,' ' end repeat repeat bytes_in_row - readable_bytes db '?? ' end repeat if bytes > bytes_in_row db 13,10,' ' end virtual bytes = bytes - bytes_in_row else end virtual break end if end while virtual Text repeat 8-bytes db ' ' end repeat db `line,13,10 end virtual end namespace end if end rmatch end macro macro nolist? end macro macro list? end macro postpone nolist end postpone |
|||
15 Oct 2017, 15:08 |
|
shoorick 11 Jul 2018, 17:18
Thanks! This variant works with new DATA macro for x51, but if there is a way to print listing into the console output (it is more convenient to me). It could be better a separate macro.
|
|||
11 Jul 2018, 17:18 |
|
Tomasz Grysztar 11 Jul 2018, 17:34
shoorick wrote: Thanks! This variant works with new DATA macro for x51, but if there is a way to print listing into the console output (it is more convenient to me). It could be better a separate macro. Code: Listing? = 1 namespace Listing base = $$ offset = $ virtual at 0 HexDigits:: db '0123456789ABCDEF' end virtual end namespace macro ? line& line rmatch =nolist?, line Listing? =: 0 else rmatch =list?, line restore Listing? else if Listing namespace Listing if ~ $$ eq base base = $$ offset = $$ end if bytes = $ - offset if $ - bytes < $$ bytes = $ - $$ end if offset = $ address = (offset scale 0)-bytes repeat 8 load digit:byte from HexDigits:((address) shr ((%%-%) shl 2)) and 0Fh display digit end repeat display ': ' if bytes < 0 bytes = 0 end if while bytes > 0 if bytes > 8 bytes_in_row = 8 else bytes_in_row = bytes end if if $ - bytes + bytes_in_row <= $@ readable_bytes = bytes_in_row else if $ - bytes >= $@ readable_bytes = 0 else readable_bytes = bytes_in_row - ($ - $@) end if load data:readable_bytes from $ - bytes repeat readable_bytes load digit:byte from HexDigits:(data shr ((%-1) shl 3 + 4)) and 0Fh display digit load digit:byte from HexDigits:(data shr ((%-1) shl 3)) and 0Fh display digit,' ' end repeat repeat bytes_in_row - readable_bytes display '?? ' end repeat if bytes > bytes_in_row display 13,10,' ' bytes = bytes - bytes_in_row else break end if end while repeat 8-bytes display ' ' end repeat display `line,13,10 end namespace end if end rmatch end macro macro nolist? end macro macro list? end macro postpone nolist end postpone Last edited by Tomasz Grysztar on 11 Jul 2018, 18:18; edited 1 time in total |
|||
11 Jul 2018, 17:34 |
|
shoorick 11 Jul 2018, 18:15
Very nice! It works! Thanks!
_________________ UNICODE forever! |
|||
11 Jul 2018, 18:15 |
|
Tomasz Grysztar 14 Jul 2018, 12:48
And here is a new version of the first listing variant, the one that lists file offsets and not addresses, modified to generate .LST file:
Code: define Listing namespace Listing offset = $%% virtual at 0 HexDigits:: db '0123456789ABCDEF' end virtual virtual as 'lst' Text:: end virtual end namespace macro ? line& line namespace Listing undefined_bytes = $% - $%% defined_bytes = $%% - offset if $ - undefined_bytes - defined_bytes < $$ defined_bytes = $ - undefined_bytes - $$ end if offset = $%% virtual Text repeat 8 load digit:byte from HexDigits:((offset-defined_bytes) shr ((%%-%) shl 2)) and 0Fh db digit end repeat db ': ' end virtual column = 0 source = `line while defined_bytes load data:byte from : $% - undefined_bytes - defined_bytes virtual Text if column = 8 column = 0 db source,13,10,' ' source = '' end if load digit:byte from HexDigits:data shr 4 db digit load digit:byte from HexDigits:data and 0Fh db digit,' ' end virtual defined_bytes = defined_bytes - 1 column = column + 1 end while virtual Text repeat 8-column db ' ' end repeat db source,13,10 end virtual end namespace end macro |
|||
14 Jul 2018, 12:48 |
|
shoorick 14 Jul 2018, 16:58
why not replace those obsolete macros above to not puzzle new ones who wish to use them? also, it would be better to incorporate such usefull macros directly into the fasmg package as "include" folder (I do this at my PC) to keep them together, ready and up to date!
here is my include folder: Code: bin.inc hex.inc @@.inc listing.inc listingx.inc proc.inc shownum.inc struct.inc switch.inc union.inc utf8.inc
|
|||||||||||
14 Jul 2018, 16:58 |
|
Tomasz Grysztar 14 Jul 2018, 17:51
shoorick wrote: why not replace those obsolete macros above to not puzzle new ones who wish to use them? also, it would be better to incorporate such usefull macros directly into the fasmg package as "include" folder (I do this at my PC) to keep them together, ready and up to date! |
|||
14 Jul 2018, 17:51 |
|
Tomasz Grysztar 09 Apr 2019, 08:51
Improved versions of listing variants from this thread are now in the official GitHub repository: https://github.com/tgrysztar/fasmg/tree/master/packages/utility
|
|||
09 Apr 2019, 08:51 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.