home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug120.arc
/
MTEK.LBR
/
MTKSYM.Z80
< prev
next >
Wrap
Text File
|
1979-12-31
|
3KB
|
93 lines
; MITEKSYM
; By Ian Johnstone
; 5th July, 1988
; Loads ZBUG and reads in A.SYM, A.COM AND ControlR
BDOS EQU 5
BDVEC EQU 0D906H ;Target for BDOS jump, which
BDJMP EQU 0D911H ;then jumps to here
CR EQU 0DH
CTRLR EQU 12H ;^R re-draws the ZBUG screen
DEBUF EQU 7FFCH ;Temporary buffer for DE
PTR EQU 7FFEH ;Pointer to next char in text buffer
READV EQU 8100H ;relocated location of READ routine
TFCB EQU 5CH
TRAPV EQU 8000H ;Relocated location of TRAP routine
ZBCALL EQU 0C945H ;BDOS jump vector of ZBUG calling subroutine
;
LD HL,TRAP ;Relocate the subroutine TRAP.
LD DE,TRAPV
LD BC,100H
LDIR
LD HL,READ ;Relocate the subroutine READ
LD DE,READV
LD BC,100H
LDIR
JP READV ;Execute the program
;
TRAP: ;Is the target of the redirected ZBUG call for keyboard
;input. Returns a char from the text buffer in A
LD A,C ;Get the BDOS service number
CP 6 ;Is if for direct keyboard access?
JP NZ,BDVEC
LD A,E
CP 0FFH ;from the keyboard?
JP NZ,BDVEC ;exit if not
LD HL,(PTR)
LD A,(HL) ;Else get a char from buffer
INC HL ;Advance pointer
LD (PTR),HL ;And save it
OR A ;Z means end of text
RET NZ
LD A,CR ;If so return CR in A
LD HL,5
LD (ZBCALL),HL ;and restore BDOS call vector in ZBUG
;subroutine
RET
TEXT: DB 'RA.SYM',CR,CR,CTRLR,'RA.COM',CR,CTRLR,0
;I don't know why but the `CR,CTRLR' are necessary
;in both places
;
TEMP: ;Receives the early calls redirected from the BDOS entry
;point until a call is received from the ZBUG calling
;subroutine, when it switches the redirection point and
;passes control to TRAP
LD (DEBUF),DE ;Save it
POP DE ;Get return address
PUSH DE
LD HL,ZBCALL+2 ;And ZBUG subroutine return addr
OR A
SBC HL,DE ;Compare them
LD DE,(DEBUF) ;restore DE
JP NZ,BDJMP ;Exit if not equal
LD HL,TRAPV ;Else point ZBUG subroutine jump vector
LD (ZBCALL),HL ;at TRAP
LD HL,BDJMP ;and restore old one
LD (BDVEC+1),HL
JP TRAPV ;and pass control to TRAP
;
READ: ;Opens and reads ZBUG.COM. Redirects all BDOS calls from
;BDOS entry point to TEMP. Passes control to ZBUG
LD HL,7F00H-TRAP+TEXT ;Calculate pointer to text
LD (PTR),HL ;Save it
LD DE,TFCB ;ZBUG.COM is in TFCB
LD C,15
CALL BDOS ;Open it
LD DE,100H
PUSH DE
LOOP: POP DE ;Pointer to next Input buffer
LD HL,80H
ADD HL,DE ;Advance it by one record
PUSH HL ;Store it (DE still holds old pointer)
LD C,26
CALL BDOS ;So set it as the current buffer
LD DE,5CH
LD C,20
CALL BDOS ;Read one record into buffer
OR A ;NZ means EOF
JR Z,LOOP ;Loop for another record
POP HL ;Else clear stack
LD HL,7F00H-TRAP+TEMP
LD (BDVEC+1),HL ;Redirect BDOS calls to TEMP
JP 100 ;Execute ZBUG