[cc65] FAR handling?

From: Keates, Mark <mark.keates1eu.dendrite.com>
Date: 2005-11-01 13:31:05
Hi Uz,

What is the current state of 24 bit address handling in CC65?
Is it just some thing that can be utilized at an assembler level?

I'm wondering how, in a 'C' source file, to declare an external 
function. Should there be a wrapper to indicate the segment?
Would the import (from the example below) be expected to look 
something like:

	.import		_far_func: far

The docs begin to go into subjects like 'choosing the memory model'
but this doesn't appear complete?

I think this would be a good area to push development against as 
many of the targets (e.g. Atari, Lynx, NES) are using bank switching
models for cartridge development and this could aid us immensely.
I think previous discussion halted on trying to decide methods by
which different platforms would handle the bank selection? This
could get tricky, but perhaps these could get passed to a user 
provided macro or 'jump to' code that will perform the bank 
selection and call, e.g. replacing the statement: 

	jsr     _far_func

To all: What other thoughts have people had regarding this?
e.g. would we want a stack to push/pop current bank to, so that
a 'far' function wouldn't end with RTS but another macro or jump
to handle the return correctly?

I note too that the Atari has no "Extended memory drivers".
Perhaps these could be implemented instead?

Kind regards,
Mark

'C' :-

extern int __far__ far_func(void);

int local_func(char a)
{
	return 2*a;
}

int main(int argc, char *argv[])
{
	return (local_func(far_func()));
}

'ASM' :-

;
; File generated by cc65 v 2.10.1
;
	.fopt		compiler,"cc65 v 2.10.1"
	.setcpu		"6502"
	.smart		on
	.autoimport	on
	.case		on
	.debuginfo	off
	.importzp	sp, sreg, regsave, regbank, tmp1, ptr1, ptr2
	.macpack	longbranch
	.import		_far_func
	.export		_local_func
	.export		_main

; ---------------------------------------------------------------
; int __near__ local_func (unsigned char)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_local_func: near

.segment	"CODE"

	ldx     #$00
	lda     #$02
	jsr     pushax
	ldy     #$02
	ldx     #$00
	lda     (sp),y
	jsr     tosumulax
	jmp     L0002
L0002:	jsr     incsp1
	rts

.endproc

; ---------------------------------------------------------------
; int __near__ main (int, unsigned char**)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_main: near

	.forceimport	initmainargs

.segment	"CODE"

	jsr     _far_func
	jsr     pusha
	jsr     _local_func
	jmp     L0004
L0004:	jsr     incsp4
	rts

.endproc

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Nov 1 13:31:26 2005

This archive was generated by hypermail 2.1.8 : 2005-11-01 13:31:29 CET