cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

__sdcc_bcall.s (1461B)


      1        .include "global.s"
      2
      3        .area   _CODE
      4
      5        .globl ___sdcc_bcall
      6        .globl ___sdcc_bcall_abc
      7        .globl ___sdcc_bcall_ehl
      8;
      9; trampoline to call banked functions
     10; used when legacy banking is enabled only
     11; Usage:
     12;   call ___sdcc_bcall
     13;   .dw  <function>
     14;   .dw  <function_bank>
     15;
     16___sdcc_bcall::
     17        ex      (sp), hl
     18        ld      c, (hl)
     19        inc     hl
     20        ld      b, (hl)
     21        inc     hl
     22        ld      a, (hl)
     23        inc     hl
     24        inc     hl
     25        ex      (sp), hl
     26;
     27; trampoline to call banked functions with __z88dk_fastcall calling convention
     28; Usage:
     29;  ld   a, #<function_bank>
     30;  ld   bc, #<function>
     31;  call ___sdcc_bcall_abc
     32;
     33___sdcc_bcall_abc::
     34        push    hl
     35        ld      l, a
     36        ld      a, (#.MAP_FRAME1)
     37        ld      h, a
     38        ld      a, l
     39        ld      (#.MAP_FRAME1), a
     40        ex      (sp), hl
     41        inc     sp
     42        call    ___sdcc_bjump_abc
     43        dec     sp
     44        pop     af
     45        ld      (#.MAP_FRAME1), a
     46        ret
     47;
     48___sdcc_bjump_abc:
     49        push    bc
     50        ret
     51;
     52; default trampoline to call banked functions
     53; Usage:
     54;  ld   e, #<function_bank>
     55;  ld   hl, #<function>
     56;  call ___sdcc_bcall_ehl
     57;
     58___sdcc_bcall_ehl::
     59        ld      a, (#.MAP_FRAME1)
     60        push    af
     61        inc     sp
     62        ld      a, e
     63        ld      (#.MAP_FRAME1), a
     64        CALL_HL
     65        dec     sp
     66        pop     af
     67        ld      (#.MAP_FRAME1), a
     68        ret