It is currently Mon Aug 21, 2017 8:54 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Sat Jun 14, 2008 7:14 pm 
Offline

Joined: Thu Jul 13, 2006 3:15 pm
Posts: 177
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]


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 14, 2008 7:54 pm 
Offline
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2119
Location: Minneapolis, Minnesota, United States
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.


Last edited by Celius on Sat Jun 14, 2008 7:55 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 14, 2008 7:55 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
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?"


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 14, 2008 8:42 pm 
Offline

Joined: Wed Mar 22, 2006 8:00 am
Posts: 354
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)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 14, 2008 10:52 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
to force absolute mode in ca65:

STA a:$00D2

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 16, 2008 8:50 am 
Offline

Joined: Thu Jul 13, 2006 3:15 pm
Posts: 177
Excellent. That worked perfectly Disch.

Thanks everyone.
Al


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 26, 2012 12:58 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 18822
Location: NE Indiana, USA (NTSC)
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.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: unregistered and 11 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:  
Powered by phpBB® Forum Software © phpBB Group