git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

gbdk-lib/libc/targets/sm83/___sdcc_bcall.s

      1         .include        "global.s"
      2 
      3         .area _HOME
      4 
      5 ;; !!! ONLY WORKS WITH __sdcccall(0) calling convention
      6 
      7 ___sdcc_bcall::
      8 banked_call::                   ; Performs a long call.
      9         pop     hl              ; Get the return address
     10         ldh     a, (__current_bank)
     11         push    af              ; Push the current bank onto the stack
     12         ld      a, (hl+)        ; Fetch the call address
     13         ld      e, a
     14         ld      a, (hl+)
     15         ld      d, a
     16         ld      a, (hl+)        ; ...and page
     17         inc     hl              ; Yes this should be here
     18         push    hl              ; Push the real return address
     19         ldh     (__current_bank), a
     20         ld      (rROMB0), a     ; Perform the switch
     21         ld      l, e
     22         ld      h, d
     23         rst     0x20
     24 banked_ret::
     25         pop     bc              ; Pop return address
     26         pop     af              ; Pop the old bank
     27         ldh     (__current_bank), a
     28         ld      (rROMB0), a
     29         push    bc
     30         ret

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.