home *** CD-ROM | disk | FTP | other *** search
- ; This program changes the BDOS entry vector at address 6 so that a program
- ; running after it will not overwrite the command processor. This program
- ; is useful when one wants to debug the operation of the command processor and
- ; wants to force a debugger such as DDT or DSD to load below rather than over
- ; the command processor.
-
- ; The program works by reading the current BDOS and BIOS vectors in page 0.
- ; The command processor address is calculated by subtracting 1603h from the
- ; BIOS warmboot address stored at 0001h. If the current BDOS vector stored at
- ; 0006h is less than this, then no further protection is needed. If it is not,
- ; then an address just below the command processor is calculated. A jump
- ; instruction is placed three bytes below the command processor, and the BDOS
- ; vector is changed to point to that instruction. Until the next warm boot
- ; restores the page-0 vectors, programs that run after PROTCCP will think that
- ; the usable TPA extends only as far as the command processor (actually,
- ; slightly below it).
-
-
- org 100h
-
- ld a,(05dh) ; See if anything in command tail
- cp ' '
- jr nz,help ; If so, display built-in help
-
- ld hl,(1) ; Get BIOS warmboot address
- ld de,-1606h ; Calculate address three bytes below
- add hl,de ; ..the command processor
- ex de,hl ; Put it into DE
-
- ld hl,(6) ; Get BDOS entry address
- ld a,h ; See if BDOS already points below CPR
- cp d ; If carry, CPR address is above protected
- jr c,noneed ; ..address, and we're all set
- jr nz,prot1 ; If nonzero, we have work to do
- ld a,l ; If zero, we have to check low bytes
- cp e
-
- noneed: ; CPR already safe
- ld de,noneedmsg ; Tell the user
- jr print
-
- prot1: ; We have to work to protect CPR
-
- ex de,hl ; Now HL has address for new BDOS vectoring
- ld (6),hl ; Put it in place in page zero
- ; Put jump instruction at vector address
- ld (hl),0c3h ; JP opcode
- inc hl
- ld (hl),e ; Store low byte of real BDOS address
- inc hl
- ld (hl),d ; Save high byte of real address
- ld de,protmsg ; Tell user that CPR is protected
- jr print
- ret
-
- help:
- ld de,helpmsg
- print:
- ld c,9 ; BDOS print-string function
- jp 5 ; Invoke BDOS and quit
-
- helpmsg:
- db 13,10,10 ; CR,LF,LF
- db 'This program protects the command processor until the'
- db 13,10
- db 'next warm boot. Use it just before running a debugger'
- db 13,10
- db 'if you want to examine the command processor.'
- db 13,10,10
- db '$'
-
- noneedmsg:
- db 13,10,10
- db 'Command processor already protected.'
- db 13,10,10
- db '$'
-
- protmsg:
- db 13,10,10
- db 'Command processor now protected until next warm boot.'
- db 13,10,10
- db '$'
-
- end
-