flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > listing, target address and labels

Author
Thread Post new topic Reply to topic
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 03 Apr 2012, 22:52
I am just integrating automatic listing generation in the Z80 version of FASM and first stripped shown address from dword/qword to just words. More doesn't make sense and helps to get a good readable output. Also I integrated a switch LISTON LISTOFF which works fine (just with ; at beginning of a line, so have to be a comment).

But I am surprised about the output which is listing.asm with listing.inc (in TOOLS) is producing. If a label is used, target address is shown only in that line and not in following line. I am wondering if this is a bug or was meant to act this way for a special reason. It doesn't look nice at all and doesn't help reading very well. Hmmm. What's about it ?

By the way, if I start listing after definition of a label, the correct target address is missing at all. Okay this is because switch on/off listing but caused through behaviour above. So before I make a workaround I would like to wait if this will be treated as a bug and fixed. Razz

Sample of Z80 listing output:

Code:
      [0000]                            format binary as "p"
                                        ;LISTON
0074:        00 01 06 00 EA                           REM 1,asmcode_st,asmcode_end
                                        
      [4082]                            asmcode_st:
                                        ; ##################################################
                                         ; place own assembler code here
                                        ; ##################################################
                                        
0079:        01 AA 55                        LD      BC,$55AA
007C: [4085] C9                                 RET
                                        
                                        ; ##################################################
                                             ; end of section for own assembler code
                                        ; ##################################################
      [4086]                            asmcode_end:
                                        
007D:        76                         auto_run:    db      NEWLINE
                                        
007E: [4087] 00                                      db      0       ; statement PRINT USR 16514
007F: [4088] 02                                      db      2
0080: [4089] 0E 00                                     dw      $0E
0082: [408B] F5 D4                                   db      $F5,$D4
0084: [408D] 1D 22 21 1D 20                      dbzx    '16514'
0089: [4092] 7E 8F 01 04 00 00                         db      $7E,$8F,1,4,0,0
                                        
008F: [4098] 76                         noauto_run:      db      NEWLINE
    



But FASM does same on x86 listings:

Code:
000010D2: [000000000040C6D2]      31 C0                                xor     eax,eax
000010D4: [000000000040C6D4]      E9 9F 16 00 00                 jmp     finish_wndproc
          [000000000040C6D9]                                    wm_setfocus:
000010D9:                         80 8D 38 FE FF FF FF                or      [focus],-1
000010E0: [000000000040C6E0]      E8 3B 18 00 00                      call    create_caret
000010E5: [000000000040C6E5]      C6 45 FE 01                       mov     [notification],AEN_SETFOCUS
000010E9: [000000000040C6E9]      80 BD 36 FE FF FF 00               cmp     [was_selection],0
000010F0: [000000000040C6F0]      0F 84 12 16 00 00                    je      done
000010F6: [000000000040C6F6]      E9 52 14 00 00                    jmp     moved_window
          [000000000040C6FB]                                    wm_killfocus:
000010FB:                         C6 85 38 FE FF FF 00                 mov     [focus],0
00001102: [000000000040C702]      FF 15 2C 66 42 00                    invoke  DestroyCaret
00001108: [000000000040C708]      C6 45 FE 02                       mov     [notification],AEN_KILLFOCUS
0000110C: [000000000040C70C]      80 BD 36 FE FF FF 00              cmp     [was_selection],0
00001113: [000000000040C713]      0F 84 EF 15 00 00                    je      done
00001119: [000000000040C719]      E9 2F 14 00 00                    jmp     moved_window
          [000000000040C71E]                                    wm_hscroll:
0000111E:                         C7 85 BB FE FF FF 1C 00        mov     [sc.cbSize],sizeof.SCROLLINFO
                                  00 00                         
00001128: [000000000040C728]      C7 85 BF FE FF FF 17 00              mov     [sc.fMask],SIF_ALL
                                  00 00                         
00001132: [000000000040C732]      8D 85 BB FE FF FF               lea     eax,[sc]
00001138: [000000000040C738]      50 6A 00 FF 75 08 FF 15               invoke  GetScrollInfo,[hwnd],SB_HORZ,eax
                                  58 66 42 00                   
00001144: [000000000040C744]      0F B7 45 10                       movzx   eax,word [wparam]
00001148: [000000000040C748]      83 F8 00                             cmp     eax,SB_LINEUP
0000114B: [000000000040C74B]      74 19                            je      hscroll_left
    
Post 03 Apr 2012, 22:52
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 03 Apr 2012, 23:09
The address is listed only when it differs from the previous one - so the lines that do not change the $ value in any way are "grouped" with the origin address listed just once.

Of course you can write a different listing generator that will make output more suitable to you needs - as I already wrote elsewhere the tools that come with fasm's package are just a simple examples of how the .fas output can be processed.
Post 03 Apr 2012, 23:09
View user's profile Send private message Visit poster's website Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 03 Apr 2012, 23:21
Thanks for replying.
Ofcourse I could correct the behaviour myself for my purpose.
But I think the difference handling between address in output file and target address is - lets say - not corresponding.
So if you don't repeat the target address why is it handled different to the physical address ? This is not repeated same way but is in the same line as code.

Look as example at physical address 000010FB:
It's followed by only spaces. In the line above the physical address is not printed (only space) but followed by target address.

And even if it is only an example, examples could be made nicer if delivered with source. So if I change it to a better looking way and I post it here at the board, you maybe could change the file for future release ? Just a proposal. Anyway it's just an example and no critical file, I think. Wink

PS: I could add parameters for reducing unneccessary zeros in addresses to strip them to smaller values (word/dword instead of dword/qword) and a switch for listing on/off which was discussed in earlier discussions.
Post 03 Apr 2012, 23:21
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 04 Apr 2012, 09:02
shutdownall wrote:
Look as example at physical address 000010FB:
It's followed by only spaces. In the line above the physical address is not printed (only space) but followed by target address.
The line "wmkillfocus:" did not generate any output, so there are not output bytes listed, and thus no need to list the offset yet (the offset at which the new bytes are generated will get shown when some new bytes are made).
At the same time "wmkillfocus:" is the first line in block of two lines that were assembled at "40C6FB" address, and so address is listed with first of them, but applies to the whole block. To me it looks much more clear when the blocks of instructions that were assembled at the same address and did not move $ value are grouped this way.

And the difference in handling of file offsets and $ addresses is there because offsets in file are linked to the data, they really are the offsets of some code/data bytes, and so when some new bytes are generated, it is shown at what offset in file they are put.
While the single $ address may apply to a whole range of instructions that do not generate any data, but where $ value is nonetheless important - as in case of label definition.
Post 04 Apr 2012, 09:02
View user's profile Send private message Visit poster's website Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 04 Apr 2012, 11:52
It's okay for me and I understand how it works and how you think. Very Happy
I will treat it other way and think this version below looks much better.

The effect is, that symbols or labels will not be printed with target address but can be found out watching the line above. In most cases labels are just needed for jumps and have no other really function in the program. And if you really need a list with all labels, you could use the symbols "tool". Anyway this symbol list would be more nice to be sorted alphabetically and not in the order of definition but this is definetely another part. I know your point of view, its just an example. So this is same just a proposal. Wink

Code:
000010F6: [000000000040C6F6]      E9 52 14 00 00                        jmp     moved_window
                                                                wm_killfocus:
000010FB: [000000000040C6FB]      C6 85 38 FE FF FF 00                  mov     [focus],0 
    


I will post a new listing source code in the next days here which can be used from whom it may concern. Very Happy
Post 04 Apr 2012, 11:52
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 04 Apr 2012, 13:26
shutdownall wrote:
The effect is, that symbols or labels will not be printed with target address but can be found out watching the line above.
I think you mean the line below. Wink
Post 04 Apr 2012, 13:26
View user's profile Send private message Visit poster's website Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 04 Apr 2012, 19:38
Tomasz Grysztar wrote:
shutdownall wrote:
The effect is, that symbols or labels will not be printed with target address but can be found out watching the line above.
I think you mean the line below. Wink


No - I mean above.

[000000000040C6FB] belongs to label wm_killfocus which is the line above. Shocked
Post 04 Apr 2012, 19:38
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 04 Apr 2012, 19:49
Oh, I misunderstood you - I thought you mean that to find out what is the value of label, you have to look at the other line. And you did mean the other way around.
Post 04 Apr 2012, 19:49
View user's profile Send private message Visit poster's website Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 04 Apr 2012, 21:38
Here I have changed version of LISTING.INC which has following options and changes:

-a will include target address (default no)
-b <number> will change the number of bytes per line (default 16)

Changed is the behaviour talked above, so target address will only be printed together with byte address ($) if choosen in general by -a option.

I changed size of target address to 32 bit by default and will change to 64 bit automatically when first address with more than 32 bit is detected. Many programs do not use target addresses with more than 32 bit and this is a waste of space to just print 8 more zeroes in front of every address.

And I integrated a switch for listing on and off. You can put at any time in source ;LISTON or ;LISTOFF to activate/deactivate listing for those parts where the listing is desired (the part of program you are maybe working on). The comment has to start at the beginning of a line and only uppercase is tested. Just an easy implementation but hopefully useful. For me it's very useful to skip listing for all include files for example.

Have fun. Very Happy


Description:
Download
Filename: TOOLS.zip
Filesize: 13.33 KB
Downloaded: 455 Time(s)

Post 04 Apr 2012, 21:38
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.