home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
CPM
/
ZCPR33
/
Z3-33
/
Z33RCP02.LBR
/
RCPIOM.LZB
/
RCPIOM.LIB
Wrap
Text File
|
2000-06-30
|
6KB
|
297 lines
page
; RCP-IOM.Z80
; Command: PEEK
; Function: Display memory contents
;
; Form:
; PEEK startadr 256 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,255 ; 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 print
db ' '+80h
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
if peekbdr
call crlf
ld b,8
peek0c:
call print
db ' '+80h
djnz peek0c
ld b,16
peek0d:
call print
db ' -', '-'+80h
djnz peek0d
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 <jps>
or a ; <jps>
ret z ; <jps>
; 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 <jps>
; 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
; PRINT A AS 2 HEX CHARS
; PASHC - LEADING SPACE
if peekon or [pokeon and not pokeq] or porton
pashc:
push af ; Save a
call print
db ' '+80h
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 and not pokeq] or porton
;
;Section 5I
;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
jr z,noargs ; Arg error
call hexnum ; Convert to number
if not pokeq
call print
db ' Pok','e'+80h
call adrat ; Print at message
endif
; 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
;
; No Argument Error
;
if pokeon or porton
noargs:
call print
db ' Arg','?'+80h
jp exit
;
endif ; Pokeon or porton
;
;Section 5I+
;Command: PORT
;Function: Display or Set I/O Port Data
;
;Form:
; 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
jr z,noargs ; Abort if no port address given
call hexnum ; Get port address into DE
ld b,d ; Copy it into BC
ld c,e ; ..for I/O operation later
call print ; Print header
db ' Por','t'+80h
ld a,b ; Print high byte of port address
call pashc
ld a,c ; Print low byte of port address
call pahc
call sksp ; Skip to possible second value
jr z,portin ; Proceed with port input
portout:
call print ; Print header
db ': OU','T'+80h
push bc ; Preserve port number
call hexnum ; Get 2nd number in DE
pop bc
ld a,e
out (c),a
jr pexit
portin:
call print
db ': I','N'+80h
in a,(c)
pexit:
call pashc
jp exit
endif ; Porton
; End RCP-IOM.Z80