Re: 65816 long addressing in assembler

From: Vanessa Ezekowitz (vanessaezekowitz_at_gmail.com)
Date: 2008-10-09 10:41:42

On Thursday 09 October 2008 12:40:51 am ruud.baltissen@apg.nl wrote:
> Hallo allemaal,
>  
>  
> I'm revising my assembler. And I'm not satisfied with the way I told my
> assembler how to treat a label as long in 65816 mode. Let me show you
> what I mean:
>  
> Example:
>  
> .ba $C000			; begin address
> LABEL		.by 0, 1, 2, 3, 4
> 		lda	$C000			[1]
> 		lda	$00C000		[2]
> 		lda	LABEL			[3]
> 
> As my assembler not only checks the value but also checks the textual
> lenght of a value, it is quite obviously that line [1] should be treated
> as normal and [2] as long (). But what about [3]?

Keep it simple - have the assembler track the widths of the labels being assigned/declared, and pick the smallest operand that will work within whatever instructions reference them.  I'm going to guess .ba automatically assumes bank 0 if it isn't clearly specified, so in this case, LABEL got a 16-bit address.   Thus, the LDA should resolve to a 16-bit operand to match it.

Had you done something like  .ba $00C000 with the leading $00, then the LDA should resolve to a 24-bit address.  Ditto for something like LABEL = $00C000.

Now, if the coder decides he or she wants to fiddle with the Stack, Data Bank, Program Bank, or Direct Page registers, that idea is out the window.  You'll have to go with your idea of prefixing the operand to force 24-bit addressing where it is needed, and assuming 26-bit addressing otherwise.

-- 
"Life is full of positive and negative events.  Spend
your time considering the former, not the latter."
Vanessa Ezekowitz <vanessaezekowitz@gmail.com>

       Message was sent through the cbm-hackers mailing list

Archive generated by hypermail pre-2.1.8.