CA65 syntax question: Forcing absolute addressing mode?
Page 1 of 1

Author:  albailey [ Sat Jun 14, 2008 7:14 pm ]
Post subject:  CA65 syntax question: Forcing absolute addressing mode?

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:

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.

[Subject Fairy was here]

Author:  Celius [ Sat Jun 14, 2008 7:54 pm ]
Post subject: 

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.

Author:  blargg [ Sat Jun 14, 2008 7:55 pm ]
Post subject: 

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?"

Author:  dvdmth [ Sat Jun 14, 2008 8:42 pm ]
Post subject: 

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)

Author:  Disch [ Sat Jun 14, 2008 10:52 pm ]
Post subject: 

to force absolute mode in ca65:

STA a:$00D2

I had to do this same thing for my FF1 disassembly I did forever ago.

Author:  albailey [ Mon Jun 16, 2008 8:50 am ]
Post subject: 

Excellent. That worked perfectly Disch.

Thanks everyone.

Author:  tepples [ Thu Jan 26, 2012 12:58 pm ]
Post subject: 

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.

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group