I am using CA65 and I have a piece of code like this:
STA $00D2
which should compile as : [8D][D2][00]
but instead CA65 internally makes an optimization for me and treats the code as if I had typed this:
STA $D2
and therefore it compiles as: [85][D2]
I know that in 99% of cases I'd be happy with CA65 doing this optimization for me. But for my disassembler, I really want the code to be identical (at least until I work out all my other bugs).
Does anyone know what syntax will force it to treat it the way I want it.
Al
[Subject Fairy was here]
You could always do .db statements where you want it to be in that format. So you could just put .db $8D,$D2,$00 instead of sta $00D2. Otherwise, I don't use CA65, so I won't really be of much help.
I've never figured this out either. I just resort to something like .byte $8D $D2 $00. If it's for self-modifying code, you could just use an address > $FF, like $1D2. If it's for the 65816 when you have the direct page set so something other than $0000, .byte seems the only way. Too bad ca65 isn't documented that well. BTW, give this thread a better subject, like "Forcing ca65 to use absolute addressing for LDA $D2?"
A 65816 specification doc I have lists the following symbols which all 65816-compatible assemblers are "supposed" to acknowledge. Don't know if this will help in terms of 6502 assembly or not, nor do I know what ca65 accepts.
For addresses:
< = forced 8-bit address
| or ! = forced 16-bit address
> = forced 24-bit address
For immediate values:
< = use bits 0-7 (or 0-15 if in 16-bit mode)
> = use bits 8-15 (or 8-23)
^ = use bits 16-23 (or 16-31)
to force absolute mode in ca65:
STA a:$00D2
I had to do this same thing for my FF1 disassembly I did forever ago.
Excellent. That worked perfectly Disch.
Thanks everyone.
Al
Google ca65 force absolute brought me here.
For example, a CHR compression program I'm working on uses a buffer in an unused part of the stack page at $0100, and I need to copy 8 bytes from offset (x - 8) in the buffer to offset x. If I were to use a zero page instruction, the address would wrap within the zero page. So instead, I decided to copy from a:$00F8,x to $0100,x and eat the 8-cycle penalty for crossing a page eight times. I assembled it and disassembled it, and it appears to work.