[Coco] SDCC and other C topics

jdaggett at gate.net jdaggett at gate.net
Thu Mar 17 11:58:38 EST 2005


James

PCR relative is best used when you want position independant code. 

Using index mode and PC relative is done by:

The assembler calculates the distance from where the PC register is pointing to the 
the rountine in memory. Then adds that as an offset. The assembler issues a 
opcode for LEAx depending on the register used. The postbyte code generated is 

1xx01100 binary direct indexed mode 8 bit offset 
1xx11100 binary indirect indexed mode 8 bit offset
1xx01101 binary direct indexed mode 16 bit offset
1xx11101 binary inderect indexed mode 16 bit offset. 

The last info generated is the offset either 8 bit or 16 bit. 

This is good for taking routines and associated subroutines and/or data tables and 
placing them as a bundle anywhere in memory. This forces the offset to subroutines 
and/or data tables to  be constant distance anywhere in the 64K memory map. 


james

On 17 Mar 2005 at 10:51, James Dessart wrote:

Date sent:      	Thu, 17 Mar 2005 10:51:26 -0500 (EST)
From:           	James Dessart <james at skwirl.ca>
To:             	CoCoList for Color Computer Enthusiasts 
<coco at maltedmedia.com>
Subject:        	Re: [Coco] SDCC and other C topics
Send reply to:  	CoCoList for Color Computer Enthusiasts 
<coco at maltedmedia.com>
	<mailto:coco-
request at maltedmedia.com?subject=unsubscribe>
	<mailto:coco-
request at maltedmedia.com?subject=subscribe>

> I know 6809 assembly well enough to pull it off, but I'm wondering
> about how to decide when to use pcr addressing. I guess if the address
> isn't a constant, then it should be pcr... What do you think? We'd
> want it to be relocatable, or at least to have the option.





More information about the Coco mailing list