__sdcc_bcall.s (945B)
1 .include "global.s" 2 3 .area _CODE 4 5 .globl ___sdcc_bcall_ehl 6; 7; default trampoline to call banked functions 8; Usage: 9; ld e, #<function_bank> 10; ld hl, #<function> 11; call ___sdcc_bcall_ehl 12; 13___sdcc_bcall_ehl:: 14 push hl 15 ld h, #>__banks_remap_table 16 ld l, e ; e == new bank 17 18 ld a, (__current_bank) 19 ld l, (hl) ; l == segment 20 ld h, a ; h == old bank 21 22 ld a, e 23 ld (__current_bank), a ; new bank to __current_bank 24 25 ld a, l ; set segment 26 call .mapper_page_set 27 ex (sp), hl ; old bank is left on stack 28 inc sp 29 30 CALL_HL 31 dec sp 32 33 ex (sp), hl 34 ld a, h 35 ld (__current_bank), a 36 ld h, #>__banks_remap_table 37 ld l, a 38 ld a, (hl) 39 call .mapper_page_set 40 pop hl 41 ret