Hi,
My project is used about 200 ROM pages and 33 RAM. So FUZIX solution is not
applicable for me.

My suggestion:
1. Any function which calls (caller) banked function (callee) must
initialize frame pointer and allocate 4 bytes at (ix-4)...(ix-1).
2. To call generic callee caller must load bank address to BC register pair
and callee address to DE or IY, if _z88dk_fastcall support is required.
3. Callee is generic function. Compiler may assign bank number to extra
global symbol (like: __sdcc_bank_<function_name>) while compiling (the
symbol villbe loaded to BC before calls).
4. Callee is called as generic (near) function always within same code
section/area.
5. Add optimization to compiler to replace calls to ABS address (n*8, n=
0...7) by corresponding RST instruction (someone may want put banked_call
on one of RSTs).

Example:
_caller::
  push ix
  ld ix,0
  add ix,sp
  ld hl,4
  add hl,sp
  ld sp,hl
...
  ld bc,__sdcc_bank_callee
  ld de,_callee
  call banked_call
...

__sdcc_bank_callee equ 5
_callee::
  ...

banked_call::
  in a,(BANK_PORT)
  ld -3(ix),a
  ex de,hl
  ex (sp),hl
  ld -2(ix),l
  ld -1(ix),h
  ld hl,100$
  ex (sp),hl
  ex de,hl
  push de
  ret
100$:
  ld a,-3(ix)
  out (BANK_PORT),a
  ld c,-2(ix)
  ld b,-1(ix)
  push bc
  ret


Best regards,
Sergey Belyashov
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to