From 65e21623a9b7b261063164990da7e53118cf2094 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 9 Feb 2015 23:00:09 +0000 Subject: [PATCH] zx128: banking helpers Just filling them out for the moment. They try and use logical not real bank numbers so won't actually work yet --- Kernel/platform-zx128/zx128.s | 69 ++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/Kernel/platform-zx128/zx128.s b/Kernel/platform-zx128/zx128.s index c817d8f9..9ff6d29b 100644 --- a/Kernel/platform-zx128/zx128.s +++ b/Kernel/platform-zx128/zx128.s @@ -179,16 +179,83 @@ place_for_b: ; And BC - here place_for_c: .db 0 + .area _COMMONMEM ; ; Banking helpers ; +; FIXME: use real bank asssignments (0 is not 0 etc) +; __bank_0_1: + ld a, #1 +bankina0: + call switch_bank ; Move to new bank + pop hl ; Return address (points to true function address) + ld e, (hl) ; DE = function to call + inc hl + ld d, (hl) + inc hl + push hl ; Restore corrected return pointer + ex de, hl + call callhl ; call the function + xor a ; return to bank 0 + jp switch_bank +callhl: jp (hl) __bank_0_2: + ld a, #2 + jr bankina0 __bank_0_3: + ld a, #3 + jr bankina0 + __bank_1_2: + ld a, #2 +bankina1: + call switch_bank ; Move to new bank + pop hl ; Return address (points to true function address) + ld e, (hl) ; DE = function to call + inc hl + ld d, (hl) + inc hl + push hl ; Restore corrected return pointer + ex de, hl + call callhl ; call the function + ld a, #1 ; return to bank 0 + jp switch_bank __bank_1_3: + ld a, #3 + jr bankina1 __bank_2_1: + ld a, #1 +bankina2: + call switch_bank ; Move to new bank + pop hl ; Return address (points to true function address) + ld e, (hl) ; DE = function to call + inc hl + ld d, (hl) + inc hl + push hl ; Restore corrected return pointer + ex de, hl + call callhl ; call the function + ld a, #2 ; return to bank 0 + jp switch_bank __bank_2_3: + ld a, #3 + jr bankina2 __bank_3_1: + ld a, #1 +bankina3: + call switch_bank ; Move to new bank + pop hl ; Return address (points to true function address) + ld e, (hl) ; DE = function to call + inc hl + ld d, (hl) + inc hl + push hl ; Restore corrected return pointer + ex de, hl + call callhl ; call the function + ld a, #2 ; return to bank 0 + jp switch_bank + __bank_3_2: - ret + ld a, #2 + jr bankina3 -- 2.34.1