6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Wed May 08, 2024 9:14 pm

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Mon Apr 27, 2020 7:11 am 
Offline

Joined: Mon Apr 27, 2020 6:54 am
Posts: 7
Good morning,

how do I create these listings (whats the right terminology?) that seem to derive from disassembly processes and that contain (from left to right):

- line number,
- memory location (or programme counter?),
- hex code,
- assembly language programme,
- comments?

(see example image attached)

I want to create something similar, not primarily for debugging but for the sake of the aesthetics of these listings.
Is there a disassembler software that creates this output out of a binary file? I would need this for MAC OS.
I'm rather new in all this. I started to learn programming in assembly with AVR Assembly language. Now I built an 8-bit system for my own based on the 65C02 following Ben Eaters videos.
So far I can create hexdump listings with Hexcode (left side) and ASCII equivalents (right side), using the simple "hexdump -C [filename.rom]" command in command line.
But how can I create more complex listings like I described above? Is this hand made or the output of a programme?
(I already checked all the disassemblers listed under "Assemblers, Disassemblers, and Optimizers" in Development Tools section of 6502.org)

Thanks for any advice and help!


Attachments:
Disassembly_listings.png
Disassembly_listings.png [ 408.62 KiB | Viewed 1429 times ]
Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 27, 2020 7:40 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10800
Location: England
Welcome!

I'd call that kind of thing a listing file - it's what an assembler will produce, or can produce, when it assembles the source. It's the source which contains the comments.

Where a disassembler comes in is when you don't have the source (and you can't get it from someone else) - you take a binary, a disassembler, and a certain amount of care and attention, and you construct a source file which, when assembled, creates the same binary as you started with.

You still need to add the comments, which means understanding the intent and the structure of the code - this understanding will, in part, come from the process of coaxing the disassembler into producing a nice result. The best disassemblers will take as inputs both the binary file and some annotations and metadata: these are the bits which come from your growing understanding of the code.


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 27, 2020 7:56 am 
Offline

Joined: Mon Apr 27, 2020 6:54 am
Posts: 7
Thank you, BigEd, that was helpful!
So, I assume that the assembler is creating some kind of these listings?
I use vasm for assembling my programs written assembly. Any help on how getting these listings out of there or any other assembler that works in command line on a Mac?


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 27, 2020 8:18 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10800
Location: England
I would hope any command line assembler would oblige. Here's vasm's help:
Quote:
‘-L <listfile>’
Enables generation of a listing file and directs the output into the file <listfile>.

‘-Ll<lines>’
Set the number of lines per listing file page to <lines>.

‘-Lnf’
Do not emit any form feed code into the listing file, for starting a new page.

‘-Lns’
Do not include symbols in the listing file.


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 27, 2020 9:01 am 
Offline

Joined: Mon Apr 27, 2020 6:54 am
Posts: 7
Thanks a lot! The -L command works! The others give me an error message, think I need to play around a bit.
The format of the listing (see attached image) is fixed I assume, isn't it? So, I can't just put the assembly code to the right hand side of the hex code, correct?


Attachments:
listing.png
listing.png [ 590.82 KiB | Viewed 1409 times ]
Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 27, 2020 9:27 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8432
Location: Southern California
The assemblers I've used put it like your first picture, where the addresses and hex code are put to the left of your own source code. The also have options to show the macro expansions or not. Sometimes there's an alphabetized list at the end of all the labels and how many times they're referenced and maybe a list of line numbers that reference each one.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 27, 2020 9:29 am 
Offline

Joined: Mon Apr 27, 2020 6:54 am
Posts: 7
Thanks, GARTHWILSON! What assemblers did you use that gave you this kind of listings?

EDITED: Ok, saw them now on your page.


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 27, 2020 12:13 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
If you have a Java 1.8 run time on your system then my portable assembler tools would produce a more traditional listing.

My tools are written in Java and work on Windows and Linux (Intel & ARM). They should work on OS/X.

There is a demo here: https://github.com/andrew-jacobs/trains

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 29, 2020 11:16 pm 
Offline

Joined: Tue Jun 08, 2004 11:51 pm
Posts: 213
My disassemblers first find the first block of code to follow. It then has a blank text file with spaces with all the addresses to be covered. It puts instruction on the lines in place of the spaces. It then makes a list of every branch, subroutine call or jump address. It makes passes through the data, stopping at every jump it goes back to the list of branch, subroutine or jump address. If it has disassemble that address it goes to the next address in the table and disassembles that when it runs out of addresses I look back at the holes and determine if they look like data or instructions. If instructions, they are disassembled if not they are put into the file as data blocks. I look at the data blocks later to see if they look like strings of text if so I convert them to text. Once I made all the various passes through the data and disassembled all the destinations.
I also make comments of counts that each of the entry points is used from the table. If it is only used locally, it is usually some IF or BEGIN type code. If it is used many times from different parts of the code, it is an important routine. I start to try to figure out what the code does and make comments.
One need to be familiar with a particular processors code to begin to understand what is happening. In 6502 Y is used with some zero page for indirect references.
It is not easy. There will be many times when you've looked at one piece of code over and over and it finally makes sense.
Piece by piece it ties together. You also need to know the ports and what other ROM may be there.
Anyway, I do not just start at one end and try to threat everything as code. It will get misaligned every time you hit a data block. It will require many passes to clean up. I let my branch,call and jump address tables determine where to disassemble and were to leave possible data blocks. This method gets almost all of the code right with few exceptions. One only needs to look a the remaining part to decide if it is data values, indirect address, strings or other data types ( like graphic data ).
Dwight


Top
 Profile  
Reply with quote  
PostPosted: Fri May 01, 2020 4:21 am 
Offline
Site Admin
User avatar

Joined: Fri Aug 30, 2002 1:08 am
Posts: 280
Location: Northern California
manhattanmoments wrote:
(see example image attached)

That looks familiar! See page 21:
http://6502.org/documents/books/keith_s ... _ksmon.pdf

Sometimes I scan these documents and wonder if people will read them. I'm glad to see that sometimes they do.

Here are more listings from the same set:
http://6502.org/documents/books/keith_sproul/

_________________
- Mike Naberezny (mike@naberezny.com) http://6502.org


Top
 Profile  
Reply with quote  
PostPosted: Fri May 01, 2020 4:52 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8432
Location: Southern California
manhattanmoments wrote:
Thanks, GARTHWILSON! What assemblers did you use that gave you this kind of listings?

EDITED: Ok, saw them now on your page.

Maybe I should answer it anyway. The commercial assemblers I've used for the 65's are the 2500AD assembler (1986-1993), and Cross-32 (1993 to present), and for the PIC microcontrollers, MPASM from Microchip. My workbench computer has a Forth kernel in EPROM, including a simple assembler I wrote for it; but it does not generate a .lst file. (Being Forth however, it automatically has macro capability, and I can also put many assembly-language instructions on a single line.)

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


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 post attachments in this forum

Search for:
Jump to: