From b43b466252b6733ba9d76a5858d5afa2a6313ad1 Mon Sep 17 00:00:00 2001 From: Leo C Date: Mon, 1 Jun 2015 22:26:25 +0200 Subject: [PATCH] b0call - call functions in bank 0 from any bank --- cbios/Makefile | 2 +- cbios/bioskrnl.180 | 2 +- cbios/chario.180 | 2 ++ cbios/conbuf.180 | 4 +-- cbios/mm.180 | 79 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 4 deletions(-) diff --git a/cbios/Makefile b/cbios/Makefile index 9ea3688..65cdd7b 100644 --- a/cbios/Makefile +++ b/cbios/Makefile @@ -80,7 +80,7 @@ define cpm-bioslink = $${COMMAND} > $${OUTPUT} || exit 1;\ ERROR=0;\ grep -Ev '^[@?$$._ 0-9A-Z]{7} [0-9A-F]{4}' $${OUTPUT};\ - grep -q ':' $${OUTPUT} && ERROR=2; \ + grep -Eq ':|UNRECOGNIZED' $${OUTPUT} && ERROR=2; \ [ "$${ERROR}" != "0" ] && rm -f $@; \ exit $${ERROR} endef diff --git a/cbios/bioskrnl.180 b/cbios/bioskrnl.180 index 2a00c90..993e60e 100644 --- a/cbios/bioskrnl.180 +++ b/cbios/bioskrnl.180 @@ -232,7 +232,7 @@ set$jumps: ret - ds 64 + ds bs$stack$size bs$stack equ $ diff --git a/cbios/chario.180 b/cbios/chario.180 index 96642e9..766bf59 100644 --- a/cbios/chario.180 +++ b/cbios/chario.180 @@ -93,6 +93,7 @@ max$devices equ 3 vector$io: pop hl + push de ld de,max$devices ; default if ld a,b ; cp e ; b > max$devices @@ -106,6 +107,7 @@ exist: inc hl ld d,(hl) ex de,hl + pop de jp (hl) diff --git a/cbios/conbuf.180 b/cbios/conbuf.180 index e8dfe31..ef11813 100644 --- a/cbios/conbuf.180 +++ b/cbios/conbuf.180 @@ -16,11 +16,11 @@ cseg - mkbuf co.fifo_id, co.fifo, co.fifo_len mkbuf ci.fifo_id, ci.fifo, ci.fifo_len + mkbuf co.fifo_id, co.fifo, co.fifo_len -ico equ co.fifo_id * 3 ici equ ci.fifo_id * 3 +ico equ co.fifo_id * 3 ;-------------------------------------------------------------- diff --git a/cbios/mm.180 b/cbios/mm.180 index 90d8144..eb4135b 100644 --- a/cbios/mm.180 +++ b/cbios/mm.180 @@ -137,6 +137,85 @@ hl2p_x: ret ; +;-------------------------------------------------------------- +; Trampoline for routines in banked ram. +; Switch stack pointer to "system" stack in top ram +; Save cbar +; + extrn bs$stack + + cseg ; common! + + public _b0call +_b0call: + + ld (b0_save_hl),hl + ld (b0_save_de),de + push af + pop hl + ld (b0_save_af),hl + + pop de ;get ptr to 'function address' in de + ld hl,2 + add hl,de + push hl ;put return address on stack + + if 0 ; link80 + + ld hl,0 + add hl,sp ; + ld a,h + cp high (bs$stack-bs$stack$size) ;link80 can't process this + jr nc,$ + 5 ;skip if stack allready in common bios ram + + else + + ld hl,bs$stack-bs$stack$size + ld a,h + dec a + ld hl,0 + add hl,sp ; + cp h + jr c,$ + 5 ;skip if stack allready in common bios ram + endif + ld sp,bs$stack ; + + push hl ;save user stack pointer + in0 h,(cbar) ; + push hl ; + ld hl,b0c_ret + push hl + ld a,SYS$CBAR ; + out0 (cbar),a ; + ex de,hl ;ptr + ld e,(hl) ;get 'function address' + inc hl ; + ld d,(hl) ; + push de ;put on (switched) stack + + ld hl,(b0_save_af) ;get back users registers + push hl + pop af + ld de,(b0_save_de) + ld hl,(b0_save_hl) + ret ;go to function +b0c_ret: + ld (b0_save_hl),hl + + pop hl ; + out0 (cbar),h ; + pop hl ; + ld sp,hl ; + ld hl,(b0_save_hl) + ret ; + + +b0_save_hl: dw 0 +b0_save_de: dw 0 +b0_save_af: dw 0 + + + ;==================================================================== if 0 -- 2.39.2