.z80 title bios3 (excbios3) misc routines (memory, time...) ;**************************************** ;* * ;* EXECUTIVE BIOS * ;* for * ;* CP/M 3.XX * ;* by * ;* * ;* Glenn S. Tenney * ;* and * ;* Roger W. Chapman * ;* * ;* Copyright (c) 1983 * ;* Osborne Computer Corporation * ;* * ;**************************************** .xlist include EXCBIOSE.LIB .list PUBLIC MOVE, XMOVE public sbank,dbank,kludge ; allow xmove's PUBLIC SELMEM public time public torom ; to rom and comn stack PUBLIC ROMMV extrn dmabk ; selmem must set this too cseg ; common ;;;;;;;; warning !!!!!!!!!!! ; Read the DRI documentation carefully regarding ; move and xmove. They may not work as you might be ; led to believe from some of the wording. It is ; like this: the xmove most recently before the move ; determines the source/destination banks, any move ; resets an xmove setting. This version works with ; the stack anywhere (it is saved). MOVE: ; ; ENTRY HL = Destination address ; DE = Source address ; BC = Count ; ; EXIT HL = Next destination address ; DE = Next source address ; re-done by Glenn Tenney 1982-12-17 ld a,(kludge) ; should we kludge s/d banks or a ; 0=no previous xmove jr nz,maybed ; previous xmove, may be difficult smove: ex de,hl ; simple move ldir ; just move ex de,hl ; leaving regs aok ret ; and get out quickly maybed: ; see if a difficult xbank move ld (savesp),sp ; save crnt stack ld sp,comnsp ; and use one in common in a,(sys) ; current bank ld (ubank),a ; save current bank push hl ; save ld hl,(sbank) ; get s and d bank ld a,h cp l ; both in same bank jr nz,dmove ; no--difficult move ; same bank move (but may not be current bank) pop hl ; restore hl 1st ld a,(sbank) ; desired bank for move out (sys),a call smove ; do a simple move jp done ; move done, reset s and d bank dmove: ; move between different banks ld (rsbank),hl ; copy s and d banks for rom pop hl ; restore push ix ; save ex de,hl ; make regs look like ldir call rommv ; off to rom's move routine ex de,hl ; and back to d.r.'s way pop ix ; (used to get to rom) jp done ; and all done rommv: ld ix,(rommove) ; get address of rom's move routine jp (ix) ; off to rom's move routine (ret back) DONE: ld a,(ubank) ; restore current bank out (sys),a ; all back to what it shd be xor a ; clear kludge flag for dri ld (kludge),a ; no more xmoves in sight ld sp,(savesp) ; restore stack too RET XMOVE: ; set for cross bank moves ; ; ENTRY B = Destination bank ; C = Source bank ; ; EXIT DBANK = Destination bank ; SBANK = Source bank ; an alternate method.... ld hl,sbank ; pt to 3 byte area ld (hl),c ; source bank inc hl ld (hl),b ; destination bank inc hl ld (hl),h ; kludge to a known non-zero (h) RET PAGE cseg ; must be common SELMEM: ; ; ENTRY A = Memory bank to select ; ; EXIT None ; ; USES A-reg only! OUT (SYS),A RET PAGE ; torom ; calls rom with a common stack not user's stack ; this is for the tpa user to allow calls to rom ; This routine jumps to ROM address and switches stacks ; ; ENTRY E = ROM address (offset from 0100h) ; A, BC, HL, IX = Any necessary parameters ; ; EXIT All ROM exit parameters remain in tact ; torom: ld (savesp),sp ; save user's stack ld sp,comnsp ; pt to one in common ld d,a ; save a in a,(sys) ; get crnt bank ld (ubank),a ; save for later exit or 80h ; force into rom out (sys),a ; now ld a,d ; restore a ld d,01h ; de=01xxh call romjp ; off to the rom (via our code) push af ; save a and flags ld a,(ubank) ; incoming bank info out (sys),a ; restore bank now pop af ; all regs now restored ld sp,(savesp) ; and return ret ; with user's stack romjp: push de ; dummy up like a call to rom ret ; off to rom (addr was in de) page ; time ; this routine is used to get/set the date ; and time ; the time is being updated by the rom interrupt routine time: ret ; do nothing ; these are areas used only within this module ubank: ds 1 ; save crnt bank here going to rom ; or when flipping banks ; these are bank numbers for transfers ; they MUST be in this order ! ! ! ! ! ! sbank: ds 1 ; current source bank dbank: ds 1 ; current destination bank ; this is a kludge because dri calls xmove then selmem and then move kludge: db 0 ; nonzero = use s/d bank end