Calling the Main ROM from Option ROM
From Bitchin100 DocGarden
Jump to navigationJump to search
STDCALL:
DI
SHLD HOLDH ;Caller's HL
XCHG
SHLD HOLDD ;Caller's DE
POP H ;(HL)=Routine to Call
MOV E,M
INX H
MOV D,M ;DE=Routine to Call
INX H ;HL=Return Address
PUSH H
LXI H,OPON ;return through OPON
PUSH H
PUSH D ;Return Address
LHLD HOLDD ;Caller's DE
XCHG
LHLD HOLDH ;Caller's HL
PUSH H ; 0363, FB C9 EI, RET
lxi h,0363h ; return here ---> EI; RET
XTHL ; works in T200 and M100
jmp STD_ON
INTCALL:
SHLD INTH ;Caller's HL
XCHG
SHLD INTD ;Caller's DE
POP H ;(HL)=Routine to Call
MOV E,M
INX H
MOV D,M ;DE=Routine to Call
INX H ;HL=Return Address
PUSH H
LXI H,OPON ;return through OPON
PUSH H
PUSH D ;Return Address
LHLD INTD ;Caller's DE
XCHG
LHLD INTH ;Caller's HL
JMP STD_ON ;make sure STD_ON does not enable interrupts!
;---------------------------------------------------------
;STD_ON: Turns off the Option ROM (or turns on Standard ROM)
;dedicated to rom calls and interrupts
;---------------------------------------------------------
; modification to STDCALL to delay the
EI till the end.
.ORG 007EH
STD_ON:
PUSH PSW
PUSH H ; 26C8, F1 C9 POP PSW, RET
LXI H,26C8H ; it returns to this location --> pop psw; ret
XTHL
; return to location pushed on stack
lda 0FF45h
ani 0FEh ; manage FF45 properly
sta 0FF45h
OUT 0E8H
RET ; RET can be found at 008EH in stdrom
; in both M100 and T200
OPON: ; this code in upper ram somewhere safe, like ALTLCD
; this routine critical for proper return from
STDCALL and INTCALL
di
PUSH PSW ; Model 100 logic.
lda 0FF45h
ori 001h ; manage FF45 properly
sta 0FF45h ; sensitive - cannot take an interrupt here
; either the rom switch is screwed up, or
; PSW gets trashed, or FF45 gets trashed
; if the interrupt occurs after sta 0FF45 but before
; out E8, then we might not return to REXROM (and the
; rest of port E8 gets screwed up)
; we would return to somewhere in main rom.
OUT 0E8H
POP PSW
ei
RET