You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

296 lines
6.8 KiB

page
; Library: RCPIOM for Z34RCP
; Author: Carson Wilson
; Version: 1.1
; Date: August 12, 1989
; Changes: POKE and PORT now respond dynamically to QUIET flag,
; eliminating "noise."
; Author: Carson Wilson
; Version: 1.0
; Date: June 15, 1988
;
; Commands: PEEK, POKE, and PORT
; ------------------------------------------------------------------
;
; Command: PEEK
; Function: Display memory contents
;
; Form:
; PEEK startadr 128 bytes displayed
; PEEK startadr endadr Range of bytes displayed
if peekon
peek:
call retsave
ld hl,tbuff+1 ; Find first number
nxtpeek equ $+1 ; Pointer for in-the-code modification
ld de,100h ; Default peek address if none
call sksp ; Skip to first token (if any)
call nz,hexnum ; Get start address if any
push de ; Save starting address
ld bc,peeklen ; Compute default ending address
ex de,hl
add hl,bc
if peekchk ; Check for overflow
jr nc,peek0 ; If no overflow past FFFF, go on
ld hl,0ffffh ; Else use FFFF as ending address
peek0:
endif ;peekchk
ex de,hl ; End address in DE
call sksp ; Skip to next token (if any)
call nz,hexnum ; Get 2nd number in DE (else default)
peek1: pop hl ; HL is start address, DE is end address
if peekhdr
push hl ; Save starting address again
ld b,8 ; Output leading spaces
peek0a: call spac
djnz peek0a
ld b,16 ; Display 16 column headers
peek0b: ld a,l ; Get low byte of address
and 0fh ; Display low hex digit
call pashc
inc hl
djnz peek0b
;
; Display header for ASCII area
;
call print
db ' ',' '+80H ; Space over to ASCII area
pop hl ; Get address
push hl
ld b,16 ; Display 16 chars. ASCII header
peek0b1:ld a,l ; Get byte
and 0fh ; Mask
call pah ; Print ASCII char.
inc hl ; Next byte
djnz peek0b1
if peekbdr
call crlf
ld b,8
peek0c: call spac ; Print leading spaces
djnz peek0c
ld b,16
peek0d: call print
db ' -','-'+80h
djnz peek0d
; Print border at ASCII area
call print
db ' ',' '+80h ; Space to ASCII border
ld b,16 ; 16 dashes
peek0e: call print
db '-'+80h
djnz peek0e
endif ;peekbdr
pop hl ; Restore starting address
endif ;peekhdr
ld c,0ffh ; Use C as continue flag
call peek2 ; Do peek
ld (nxtpeek),hl ; Set continued peek address
jp exit
peek2:
ld a,c ; Check continuation flag
or a
ret z
; Print line header
peek2a: call crlf ; New line
ld a,h ; Print address
call pashc
ld a,l
call pahc
call dash ; Print leader
ld b,16 ; 16 bytes to display
push hl ; Save start address
; Print hex values for 16 bytes
peek3: ld a,(hl) ; Get next byte
call pashc ; Print with leading space
; Check for last address. If C is already 0, leave it that way.
; Otherwise check for end address and if so set C to zero.
ld a,c ; See if continue flag already cleared
or a
jr z,peek3a ; If so, skip test
ld a,h
sub a,d ; See if h = d
ld c,a
ld a,l
sub a,e ; See if l = e
or c ; Combine two tests
ld c,a
peek3a: inc hl ; Pt to next
djnz peek3
; Print ASCII equivalents for 16 bytes
pop hl ; Pt to first address again
ld b,16 ; 16 bytes
call print ; Space and fence
db ' '
db fence+80h
push bc ; Save flag in c
peek4: ld a,(hl) ; Get next byte
ld c,'.' ; Assume dot
and 7fh ; Mask it
cp ' ' ; Dot if less than space
jr c,peek5
cp 7fh ; Don't print del
jr z,peek5
ld c,a ; Char in c
peek5: ld a,c ; Get char
call conout ; Send it
inc hl ; Pt to next
djnz peek4
call print ; Closing fence
db fence+80h
pop bc ; Get flag in c back
call break ; Allow abort
jr peek2
endif ; Peekon
; PAHC - Print A as 2 hex chars
; PASHC - With leading space
if peekon or pokeon or porton
pashc:
push af ; Save A
call spac
pop af
pahc: push bc ; Save bc
ld c,a ; Byte in c
rrca ; Exchange nybbles
rrca
rrca
rrca
call pah ; Print hex char
ld a,c ; Get low
pop bc ; Restore bc and fall thru to pah
pah: and 0fh ; Mask
add '0' ; Convert to ascii
cp '9'+1 ; Letter?
jr c,pah1
add 7 ; Adjust to letter
pah1: jp conout
endif ; Peekon or pokeon or porton
; --------------------------------------------------------------------
;
; Command: POKE
; Function: Place Values into Memory
;
; Form:
; POKE startadr val1 val2 ...
;
if pokeon
poke:
call retsave
ld hl,tbuff+1 ; Pt to first char
call sksp ; Skip to non-blank
jp z,numerr ; Numerical error
call hexnum ; Convert to number
call qplug ; Shut off output if quiet
call print
db ' Pok','e'+80h
call adrat ; Print at message (quiet sensitive)
call unplug ; Turn on output
; Loop for storing hex values sequentially via POKE
poke1: push de ; Save address
call sksp ; Skip to non-blank
jp z,exit ; Done
cp '"' ; Quoted text?
jr z,poke2
call hexnum ; Get number
ld a,e ; Get low
pop de ; Get address
ld (de),a ; Store number
inc de ; Pt to next
jr poke1
; Store ASCII chars.
poke2: pop de ; Get next address
inc hl ; Pt to next char
poke3: ld a,(hl) ; Get next char
or a ; Done?
jp z,exit
ld (de),a ; Put char
inc hl ; Pt to next
inc de
jr poke3
endif ; Pokeon
; -------------------------------------------------------------------
;
; Command: PORT
; Function: Display or Set I/O Port Data
;
; Forms:
; PORT addr - Read port and display value
; PORT addr value - Output value to port
;
if porton
port:
call retsave
ld hl,tbuff+1 ; Find first number
call sksp ; Skip to first command-line token
jp z,numerr ; Numerical error
call hexnum ; Get start address into de
push hl ; Save pointer to command tail
ld hl,portadl ; Modify code
ld (hl),e ; Move specified port addr into place
dec hl ; Point to opcode position
ld (hl),0dbh ; Poke 'in' opcode
dec hl
ld (hl),d ; Save MSB for port address
inc hl
ex (sp),hl ; Get tail pointer back while saving this one
call qplug ; Shut off output if quiet
call print ; Print header
db ' Por','t'+80h
ld a,e
call pashc ; Print port address
call sksp ; Skip to possible second value
jr z,portin ; Proceed with port input
call hexnum ; Get 2nd number in de
ex (sp),hl ; Get pointer to opcode back
ld (hl),0d3h ; Poke 'out' opcode
call print
db ': OU','T'+80h
ld a,e ; Get value to output
jr paddr
portin:
call print
db ': I','N'+80h
xor a ; Make sure high port address = 0 (for hd64180)
portadh equ $+1
paddr: ld b,0 ; ..for both in and out instructions
opcode:
db 0 ; Opcode for in or out inserted by code above
portadl:
db 0 ; Port address inserted by code above
call pashc
call unplug ; Turn on output
pop hl ; Clean up stack
jp exit
endif ; Porton
; End RCPIOM.Z80