Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listing Output #15

Closed
AntiBlueQuirk opened this issue Jul 25, 2019 · 1 comment
Closed

Listing Output #15

AntiBlueQuirk opened this issue Jul 25, 2019 · 1 comment

Comments

@AntiBlueQuirk
Copy link

AntiBlueQuirk commented Jul 25, 2019

Great tool! (Kept me from having to write my own assembler for my CPU. :) )

Would it be hard to add an "annotated hex listing output"? I looked a little at the output formats, and it didn't look like any of them have this sort of support.

I'm thinking something like this:

### Input:

#addr 0x80
lda #10
.loop:
sbc #1
out A
bnz .loop ; loop til zero

### Output:

; File: <input>:0
; #addr 0x80
0x80  01 0A    ; lda #10
; .loop:
0x82  0B 01    ; sbc #1
0x84  2C       ; out A
0x85  27 FA    ; bnz .loop ; loop til zero

Basically, the output would be something you might get if you ran the output of the tool back through a disassembler. Except that the tool can cheat, since it could know exactly what line corresponds to each group of bytes that was emitted.

If you're watching a simulated CPU, it would be very easy to follow this listing by following your CPU's PC. It would also be massively useful for just telling if your program is assembling to what you expect. (Emitting proper instructions and so on.)

I wouldn't mind contributing some code to this, but I'm not very familiar with Rust (yet), and I'm even less familiar with the architecture of this tool, so I don't know if the assembler even retains enough information for this feature to be feasible. If it doesn't keep some sort of mapping between the output bytes and the source line, I can imagine this might be a pretty invasive change.

Maybe this would work best as an additional output? That way the assembler can just write to the "listing log" as it goes along, and doesn't have to remember a bunch of extra information to produce an output.

@hlorenzi
Copy link
Owner

This is a really good idea! It's very much doable, but you're right in that it will require a little more bookkeeping inside the assembler -- but probably nothing too troublesome. I'll try working on it when I have the time! Should become a good default output format when it's done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants