flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
Tomasz Grysztar 14 Oct 2016, 05:57
jmg wrote: I think here you talk about some internal operations ? jmg wrote: Just had fasmg freeze/never exit.... |
|||
![]() |
|
jmg 14 Oct 2016, 08:55
This code fails..
Code: ; P8X32_PropMacros.asm ; include 'hex.inc' ; comment to create Binary image - change MAKE.CMD if inactive. include 'listing.inc' ; Include this to enable .LST generate dd 20_000_000/4 ; waitx param ORG 0 dd 20_000_000/4 ; waitx param dd 20_000_000 but checking I see it does seem to need that listing.inc in order to fail - from another post Code: define Listing namespace Listing base = $$ offset = $ macro disphex number*,digits:8 repeat digits digit = ((number) shr ((%%-%) shl 2)) and 0Fh if digit < 10 display '0'+digit else display 'A'+digit-10 end if end repeat end macro end namespace macro ? line& line namespace Listing if ~ $$ eq base base = $$ offset = $$ end if bytes = $ - offset if $ - bytes < $$ bytes = $ - $$ end if offset = $ disphex (offset scale 0)-bytes,8 display ': ' column = 0 while bytes if column = 8 column = 0 display 13,10,' ' end if load data:byte from $ - bytes disphex data,2 display ' ' bytes = bytes - 1 column = column + 1 end while repeat 8-column display ' ' end repeat display `line,13,10 end namespace end macro |
|||
![]() |
|
Tomasz Grysztar 14 Oct 2016, 10:14
I see, you still use the old, buggy version of that macro. I corrected it later. The problem lies here:
Code: while bytes ; ... bytes = bytes - 1 end while Since "while bytes" is equivalent to "while bytes <> 0", when initial value is negative you get infinite loop. The correction that I included in the other thread was simply to change it to: Code: while bytes > 0 |
|||
![]() |
|
jmg 17 Oct 2016, 00:50
Tomasz Grysztar wrote: I see, you still use the old, buggy version of that macro. I corrected it later. thanks, I applied that, but now I notice this effect change of just a single line to include older or newer listing.inc, yields include 'listing_o2.inc' ; older gives 1 pass, 1.1 seconds, 16520 bytes. include 'listing.inc' ; newer gives 2 pass, 2.4 seconds, 16520 bytes Something in that fixed code, is forcing a second pass ? Suggestion: I think you can still edit the first post,in that thread ? It can be easier to find/follow, if the lastest version, with a version number, is included in the first post - ie the first post has the revisions, and readers do not need to trawl/merge to find latest. Last edited by jmg on 17 Oct 2016, 01:44; edited 1 time in total |
|||
![]() |
|
jmg 17 Oct 2016, 01:17
some more info, when I apply this, combined with the HEX.INC macros, these effects are seen
include 'hex.inc' ; include 'listing.inc' ; latest, gives 2 passes, 27.4 seconds, 46482 bytes. include 'hex.inc' ; older 1 pass, 9.6 seconds, 46482 bytes. include 'listing.inc' and the pairing somehow effects listing, and it bumps from 4162 lines to 7910 lines. Bonus lines look to all be 18 spaces per line. This source can give 1 pass, 1.1 seconds, 16520 bytes, without hex.inc and older listing version. |
|||
![]() |
|
Tomasz Grysztar 17 Oct 2016, 07:49
Are you using this listing combined with the faster disphex macro I suggested elsewhere? It was written in a hurry and I had a small mistake there. This line:
Code: load digit from HexDigits:((number) shr ((%%-%) shl 2)) and 0Fh should have been Code: load digit:byte from HexDigits:((number) shr ((%%-%) shl 2)) and 0Fh |
|||
![]() |
|
jmg 17 Oct 2016, 20:51
Thank's - I've updated my listing.
That still does not explain why the 'improved' listing code change bumps to 2 passes ? (which has a significant slow down effect). Likewise, the hex.inc and Listing.inc seem to interact badly, and slow down more. These speed-impacts are large - in all cases the file-info is the same, and the same code comes out the other end, just in Binary or hex and with/without listing. No Listing, Binary out: 1 pass, 0.2 seconds, 16520 bytes. Earlier 1 pass Listing 1 pass, 1.1 seconds, 16520 bytes. add hex.inc 1 pass, 9.6 seconds, 46482 bytes. Newer 'hex.inc' & 'listing.inc' 2 passes, 27.4 seconds, 46482 bytes. but there are bugs in there, as the pairing somehow effects listing, and it bumps from 4162 lines to 7910 lines. Bonus lines look to all be 18 spaces per line. Those speed impacts look to make a good case for having HEX & LST as a native options in fasmg, as they are pretty fundamental assembler leg-work. |
|||
![]() |
|
Tomasz Grysztar 17 Oct 2016, 21:30
jmg wrote: but there are bugs in there, as the pairing somehow effects listing, and it bumps from 4162 lines to 7910 lines. Bonus lines look to all be 18 spaces per line. jmg wrote: Those speed impacts look to make a good case for having HEX & LST as a native options in fasmg, as they are pretty fundamental assembler leg-work. |
|||
![]() |
|
jmg 17 Oct 2016, 22:18
Tomasz Grysztar wrote: I would need to see the exact versions of these macros that you use, the best would be the complete set of files to reproduce the problem. I'll try to attach:
|
|||||||||||||||||||||||||||||||
![]() |
|
jmg 17 Oct 2016, 23:18
Tomasz Grysztar wrote:
I can understand that, but native support does not have to exclude macros & their flexible use. Macro's have pluses, but for these most basic of tasks, 'flexible' matters less than speed, and those speed impacts are significant. 0.2s to 27s is a massive hit ! Intel hex especially, is very well defined, and is simply an output format-variant. Even a LST file is not widely variable, they all follow the same rules. Address: Hex Info : Source line fragment. Given the interaction of macros here, maybe it is better to just include a BIN2HEX separate pgm with fasmg, that can work on the BIN output. A good (but old) example is here, has most of the options users need... http://www.keil.com/download/docs/113.asp I'd also like to see a dbhex choice, aka ASCII hex, but as ASM INCLUDE format as ORG OptionalOffsetValue DB 0x01,0x02, etc also has mention of srec_cat, and download of this https://sourceforge.net/projects/srecord/files/srecord-win32/ then run as srec_cat P8X32_PropMacros.bin -binary -o P8X32_PropMacros.hex -intel seems very fast. and it even has the DB output too... ![]() srec_cat P8X32_PropMacros.bin -binary -o P8X32_PropMacros.DB -ASM Looks like a better HEX solution all round, and that leaves Listings... Addit: Strange, I was unable to get any of the documented -ASM options to stick, and even srec_cat -Help fails too ? Lucky for me, the defaults are tolerable. Last edited by jmg on 18 Oct 2016, 00:27; edited 1 time in total |
|||
![]() |
|
jmg 17 Oct 2016, 23:33
Tomasz Grysztar wrote: ...the self-assembly of fasmg as either PE or a relocatable ELF object takes 7-8 seconds here, this is in fact similar time to how long the self-assembly of fasmw originally lasted on my good old Pentium 60 MHz)... Now that's cool & would make a good demonstration. Suggestion: Can you include a directory in the install, that can do that self-assembly of fasmg ? addit: this seems to work ? Is it really this simple ? ..\fasmg windows/fasmg.asm fasmg.exe Reports: flat assembler g version 0.99.1476366664 4 passes, 14.5 seconds, 50176 bytes. |
|||
![]() |
|
Tomasz Grysztar 18 Oct 2016, 09:21
jmg wrote: I can understand that, but native support does not have to exclude macros & their flexible use. Thus what you are looking for is perhaps a specialized assembler based on this engine, like the nonexistent fasm 2. I'm going to work on my fasmg-based "assembler construction kit" for this purpose, but it would still require some able and interested people that could use such kit to make actual assemblers, and this would probably be a bit harder for a third person compared to writing macro packages for fasmg (though when one is accustomed to x86 assembly, then not that much harder, the internal interfaces of fasmg engine are relatively simple to use). jmg wrote: Can you include a directory in the install, that can do that self-assembly of fasmg ? |
|||
![]() |
|
jmg 18 Oct 2016, 09:51
Tomasz Grysztar wrote: ... I know that the idea behind fasmg is a bit insane, but it is just a culmination of what I've been doing for years with fasm and I find it very inspiring.. It might not be main-stream, but fasmg is more 'great' than 'a bit insane' ![]() |
|||
![]() |
|
Tomasz Grysztar 18 Oct 2016, 10:03
jmg wrote: I'll try to attach: Code: Listing? = 1 namespace Listing base = $$ offset = $ virtual at 0 HexDigits:: db '0123456789ABCDEF' end virtual macro disphex number*,digits:8 repeat digits load digit:byte from HexDigits:((number) shr ((%%-%) shl 2)) and 0Fh display digit end repeat end macro end namespace macro nolist? end macro macro list? end macro 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 = $ disphex (offset scale 0)-bytes,8 display ': ' column = 0 while bytes > 0 if column = 8 column = 0 display 13,10,' ' end if load data:byte from $ - bytes disphex data,2 display ' ' bytes = bytes - 1 column = column + 1 end while repeat 8-column display ' ' end repeat display `line,13,10 end namespace end if end rmatch end macro |
|||
![]() |
|
Tomasz Grysztar 18 Oct 2016, 10:08
Oh, and by the way: you can also use that NOLIST switch to disable listing before the HEX macros start to generate their data:
Code: include 'hex.inc' include 'listing.inc' ; postponed blocks are executed in reverse order, so this should get executed before HEX writer: postpone nolist end postpone |
|||
![]() |
|
Tomasz Grysztar 18 Oct 2016, 13:03
I have noticed that the listing macro can also be made a bit faster by unrolling some loops and reading data in larger portions:
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 load data:8 from $ - bytes repeat 8 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 bytes = bytes - 8 display 13,10,' ' else load data:bytes from $ - bytes repeat 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 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 Also the HEX macro can be sped up a tiny little bit, by using the same look-up table trick: Code: virtual at 0 HEX.digits:: db '0123456789ABCDEF' end virtual macro HEX.byte value HEX.checksum = (HEX.checksum + (value)) and 0FFh local digit load digit:byte from HEX.digits:(value) shr 4 db digit load digit:byte from HEX.digits:(value) and 0Fh db digit end macro Last edited by Tomasz Grysztar on 18 Oct 2016, 20:45; edited 1 time in total |
|||
![]() |
|
jmg 18 Oct 2016, 19:50
Thanks, wow, that's a large improvement. Faster, and interactions gone.
It now gives ; Improved 19th oct hex and listing now gives ; 1 pass, 0.8 seconds, 16520 bytes. Listing only ; 1 pass, 1.3 seconds, 46482 bytes. Listing & Hex Request: when publishing, can you include a heading something like ; Listing.inc macro, version 1.2.1510 https://board.flatassembler.net/topic.php?p=191113#191113 ; Purpose: Create a listing output on Display of Adr: Hex Hex ... Source Line Portion & ; hex.inc Macro, version 1.2.1510 https://board.flatassembler.net/topic.php?p=191113#191113 ; Purpose : output file changes to intel hex format, instead of default Binary. ie shows name, version number, and a link where any updates can be found. Those updates should be refreshed in the first post of that link. |
|||
![]() |
|
Tomasz Grysztar 18 Oct 2016, 19:54
I have updated my above post just before you answered, with some additional corrections - lines without data were not indented properly.
The improved HEX macro is now in the official package. For the new listing macro I have not yet decided where to publish it. |
|||
![]() |
|
jmg 18 Oct 2016, 20:16
Tomasz Grysztar wrote: I have noticed that the listing macro can also be made a bit faster by unrolling some loops and reading data in larger portions: There is I think a small formatting bug in listing : Code: 00000000: define WC2 SUFF 10b 00000000: define WZ2 SUFF 01b 00000000: ORG 0 00000000: FB F7 23 F6 NOT DIRB 00000004: lp: 00000004: FD FB 23 F6 NOT _OUTB 00000008: 25 26 80 FF 28 80 66 FD WAITX #20_000_000/4 00000010: F0 FF 9F FD jmp lp 00000014: R5 EQU 5 00000014: 28 FC 67 FD WAITX #510 00000018: 28 0A 60 FD WAITX R5 0000001C: 28 46 66 FD WAITX #$123 00000020: 28 46 62 FD WAITX $123 00000024: 44 33 22 11 dd 0x11223344 00000038: FirstEQU EQU 0x55 00000038: 55 DB FirstEQU 00000039: 53 69 6D 70 6C 65 20 53 74 72 69 6E 67 DB 'Simple String' 00000046: 21 DB 33 00000047: DB 0F 49 40 DD 3.141592653589793238462643 0000004B: 18 2D 44 54 FB 21 09 40 DQ 3.141592653589793238462643 00000053: 0B DB 11 00000054: ccDef EQU 1111b shl 18 Note DQ and other 8-byte lines, do not column-align, but bump to next line. Also, source equates,defines etc I think should all be source-column placed, so the ideal .LST is formatted like this : Code: 00000000: define WC2 SUFF 10b 00000000: define WZ2 SUFF 01b 00000000: ORG 0 00000000: FB F7 23 F6 NOT DIRB 00000004: lp: 00000004: FD FB 23 F6 NOT _OUTB 00000008: 25 26 80 FF 28 80 66 FD WAITX #20_000_000/4 00000010: F0 FF 9F FD jmp lp 00000014: R5 EQU 5 00000014: 28 FC 67 FD WAITX #510 00000018: 28 0A 60 FD WAITX R5 0000001C: 28 46 66 FD WAITX #$123 00000020: 28 46 62 FD WAITX $123 00000024: 44 33 22 11 dd 0x11223344 00000038: FirstEQU EQU 0x55 00000038: 55 DB FirstEQU 00000039: 53 69 6D 70 6C 65 20 53 74 72 69 6E 67 DB 'Simple String' 00000046: 21 DB 33 00000047: DB 0F 49 40 DD 3.141592653589793238462643 0000004B: 18 2D 44 54 FB 21 09 40 DQ 3.141592653589793238462643 00000053: 0B DB 11 00000054: ccDef EQU 1111b shl 18 All source lines are now column justified, and a column-copy in editor, will 'get-back' the source. This also allows LST parsing in the HEX Data columns, as source is never present there. |
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.