-
Notifications
You must be signed in to change notification settings - Fork 4
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
Absolute / zeropage addressing not working as expected #8
Comments
I looked through about 25% of my code and there appears to be three occurrences that create differeneces between the original binary and the dissassembled/reassembled binary (with as65):
I suspect that the missing bytes due to 1. are likely to be data items anyway, so I will add data statements to those and see how I get on. I spent a couple of hours trying out a handful of different assembler to assemble the dasmfw output and it appears so far none of them are as compatibile as as65, perhaps because it's quite old, generally they use .word, .const and simlar to handle FCB, EQUs etc. None of the assemblers are consistent with each other, so your idea of tailoring output to specific assembers is likely to be necessary. Now I will push forward with as65 and attempt to get my dasmfw output source code to assemble and the look at other functionaly. I suspect I may then get other problems with incompatibilities, but let's see. I came across another disassembler/assembler pair, namely BeebAsm/BeebDis (Pages 1 & 8) (although they are written by different people). BeebDis seems to have a similar philosophy to dasmfw....
...and includes some options for formatting output for an arbitrary assembler...
I'm not sure how mature/compatible this BeebDis/BeebAsm combo is, but it's probably worth a look. It didn't seem to have the same depth of functionalality as dasmfw, but I only had a quick look. I'll let you know how I get on with progress with as65. |
I suspected right. 26 Next step is to try some more dasmfw formatting commands. |
What would be better in your opinion:
Convenience vs. flexibility vs. necessity ... if 100% of all use cases require the same setting for both, a separate option would be counterproductive ... |
My gut feeling says one option only. Given the register name is included in the mnemonic name e.g. 3rd character of I don't think I've seen that inconsistency in any of the docs for assemblers I've looked at recently, except in the DASM manual, though I don't believe it's a requirement to enter code that way. The manual states case-insensitive for several features, although not regarding register names specifically: |
I've uploaded a bigger update plus executable in https://github.com/Arakula/dasmfw/releases/tag/v0.26 that ...
|
Thanks for the code update! I can confirm that my raw dasmfw v0.26 disassembly now reassembles successfully with as65, without any manual changes to the diassembled source code. I'm using 26 dasmfw I reviewed your "TODO" header text. From what I have ascertained recently, "<" and ">" are often used to assemble the top or bottom byte of an assembler variable, for an 8-bit CPU, I guess that could be quite useful. Regarding using $00 or $0000 to decide on absolute or zeropage, I don't think that's a bad solution to the problem if that's all that the assembler will accomodate, even if it's just a default method (though I appreciate it might be difficult to implement). However, I would question how robust a disassembly solution can ever be for absolute or zeropage addressing. I don't know why the programmer would want to force an absolute address, maybe for a special cycle-timing need, but otherwise I'm thinking you'd only ever do it sparingly. Unfortunately that will fool the disassembler often and you can never do anything about having the issue in data blocks. All you can really do for certain is manually force the address mode from the info file, like I'm doing (although it could me more elegent that the As I attempt to disassemble the jetpac binary, we'll see how usable dasmfw is overall, as there may be many formatting issues that aren't going to work and this will probably be the same for all assemblers, not just as65. I guess it'll be a question of identifying the disassmebly elements that need a specifc format and then working out the best way of specifying them. Then, ideally, you'd be able to set a group of formats to define a specific assembler, but that's an ideal scenario, you may have other priorities! Anyway, I'll push forward with the detail of my disassembly and report back progress. BTW, I also found yet another way of denoting absolute or zeropage:
|
That is, in the long run, precisely what I plan to do. Solve the problem once and for all. But that will take time and careful planning, as there are so many options for the simplest things, even for the few disassemblers I have already implemented. |
One scenario comes to my mind: a one-pass assembler with some code on the zero page referencing data that comes a bit later. A two-pass assembler might flag this as a phase error. |
I've invested a silent hour into writing up some basics. Might as well share them with you, maybe you have some inputs ...
That's it for today. Comments, precisions, etc. are very welcome. |
Perhaps the best/only way to really get a good specification up front of how the classes would work is to start with an in depth review of a number of assemblers and make a big table with how each aspect is handled, I'm thinking the core set of aspects is probably not that so big. The agile approach would be to get one assembler working and them make it work for two different assemblers and make up the specification as you're going along. The alternative approach would be to extend your own assembler. Sorry I can't be of more help...but hopefully my feedback as I'm using dasmfw with as65 will be useful. Potentially I'll move to one of the other assemblers that can output a symbol file to MAME or VICE, but until then, I can probably fabricate something using awk. |
It would appear that the SB Assembler, which covers many CPUs and has a long history, does use > and < for forced absolute and zero page addressing on 6502. https://www.sbprojects.net/sbasm/6502.php |
I've added a crude method to deal with this now.
(see syntax for that weird string pattern in dasmfw.htm). ... although I fear it isn't. At least for the 68HC11, I've come across an assembler that requires a * as parameter prefix if an address is to be forced to direct page addressing, as it would use extended addressing otherwise. That's a behavior that dasmfw doesn't really deal with at the moment (it assumes things work the other way - a decent assembler should use direct page addressing when possible and only use extended addressing when forced to). |
I notice this issue is still open. My originally stated problem appears resolved now that dasmfw can force a particular addressing, either zero-page or absolute (in 6502 terms). However, it can only work successfully if the original assembler was forced to use absolute addressing I'm presuming a force usage of zero-page is unlikely, as it will not work if the jump target address is to far away. Nonetheless, as you suggested, my problem with incorrect addressing is probably due to it appearing in what will likely be data areas, so I'm manually working around the issue without using forced addressing. If you're using this issue as a placeholder for future work, fine by me to leave it open, but otherwise feel free to close the issue. |
You may be, but I'm not fully done with this issue yet. You see, while there's presumably no 6502 assembler that doesn't automatically use ZP addressing in doubt, I recently came across some old source code for a Motorola 68HC11E1 that obviously defaults to extended addressing, at least for data items defined with a RMB (or .ds in that one's syntax) instruction, and requires prefixing the parameter with a '*' if direct addressing is wanted. While stupid (leads to an insane amount of *s in the code and waste of space and CPU cycles because it's so easy to forget the *, in which case the long form is generated), dasmfw currently can't easily reproduce that, except by putting an equally insane amount of |
The extra inserted 00 is the "brk" that dasmfw invented (so the second 00 should be red). |
Yes, it noticed that. BTW, my nfo file is here: https://github.com/phillipeaton/JETPAC_VIC-20_disassembly/blob/main/nfo_jetpac.nfo You may recall I had many lines of |
OK, should be fixed in https://github.com/Arakula/dasmfw/releases/tag/v0.30 |
Tonight's test shows that it appears to be fixed, many thanks! 😀 |
Following on from the
forceaddr off
issue, I had a problem with as65 not assembling and that's why I was attempting workarounds withforceaddr
:A bit of research shows that the 6809-style >z009d isn't used for 6502 assembly. Here are some assembler manual links that describe how they deal with absolute and zeropage addressing.
This in the best description: ACME Assembler
This is also good: KickAssembler
And this one: DASM (PDF page 61/62, manual page 52/53)
And one more that shows it in action:

Generally it seems, there are two ways of managing absolute/zero page addressing:
.z
or.a
to thelda
.It seems to me that all the assemblers I looked at recognize 1. and newer assemblers recognize 1. & 2. There appear to be other forcing parameters also that some assemblers recognize, but I'm not sure they're really necessary, Kick Assembler has specifically deprecated them all, apart from
.z
/.a
.The as65 assembler specifically complains about the
jsr >z009d
, probably becausejsr
is always uses a 16 bit address. I get fourjsr
errors in my listing, but there are many other instructions with this address mode e.g.asl >m0000
that do not throw an error. It would appear '>' is valid for addresses, but, from what I can tell, it's for manipulating the address data at assemble time, not selecting address mode. I still have a lot of non-matching code between the original binary and the dissassembled/reassembled binary, so I will look into this a bit more and report back.The text was updated successfully, but these errors were encountered: