mirror of https://github.com/wwarthen/RomWBW.git
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.
165 lines
3.8 KiB
165 lines
3.8 KiB
page
|
|
|
|
; Library: RCPREG for Z34RCP
|
|
; Version: 1.1
|
|
; Date: August 11, 1989
|
|
; Changes: Register Set, Decrement, and Increment commands now respond
|
|
; dynamically to QUIET flag, eliminating "noise."
|
|
|
|
; Author: Carson Wilson
|
|
; Version: 1.0
|
|
; Date: June 15, 1988
|
|
;
|
|
; Command: REG
|
|
; Function: Manipulate Memory Registers
|
|
;
|
|
; Forms:
|
|
; REG D or REG <-- Display 10 Register Values
|
|
; REG Mreg <-- Decrement Register Value
|
|
; REG Preg <-- Increment Register Value
|
|
; REG Sreg value <-- Set Register Value
|
|
;
|
|
; Vers 2.1 Joe Wright
|
|
;
|
|
; REG reg <-- Display a single register value
|
|
;
|
|
; REG numbers now range from 0 to 31, although only the first ten are
|
|
; displayed with REG D.
|
|
;
|
|
; REG now treats the program error byte as register E.
|
|
;
|
|
register:
|
|
ld de,fcb1+2 ; Pt to first arg
|
|
ld a,(de) ; Get possible digit
|
|
call regptr ; Pt hl to potential register
|
|
dec de ; Point to command
|
|
ld a,(de)
|
|
cp 'S' ; Set?
|
|
jr z,rset
|
|
cp 'P' ; Plus?
|
|
jr z,rinc
|
|
cp 'M' ; Minus?
|
|
jr z,rdec
|
|
cp ' '
|
|
jr z,rshow
|
|
cp 'D'
|
|
jr z,rshow
|
|
call regptr
|
|
jp regout
|
|
|
|
; Increment register value
|
|
; HL pts to memory register on input
|
|
|
|
rinc: inc (hl) ; Increment it
|
|
jr Qregout ; Print result
|
|
|
|
; Decrement register value
|
|
; HL pts to memory register on input
|
|
|
|
rdec: dec (hl) ; Decrement value
|
|
jr Qregout ; Print result
|
|
|
|
; Show first ten registers and Program Error byte
|
|
|
|
rshow: call rshow10
|
|
ld hl,z3msg+6
|
|
jp regout
|
|
|
|
rshow10:xor a ; Select register 0
|
|
ld b,a ; Counter set to 0 in b
|
|
call regp1 ; Hl pts to register 0
|
|
rshow1: ld a,b ; Get counter value
|
|
cp 10 ; First ten registers
|
|
ret z ; Exit if done
|
|
push bc ; Save counter
|
|
push hl ; Save pointer
|
|
call regout ; Print register value
|
|
pop hl ; Get pointer
|
|
pop bc ; Get counter
|
|
inc b ; Increment counter
|
|
ld a,b ; Check for new line
|
|
and 3
|
|
call z,crlf ; Newline after fourth display
|
|
inc hl ; Pt to next register
|
|
jr rshow1
|
|
|
|
; Set register value
|
|
; HL pts to register on input
|
|
|
|
rset:
|
|
ld de,fcb2+1 ; Pt to value
|
|
call de2bin ; Eval string at de to binary in b
|
|
ld (hl),b ; Set value
|
|
|
|
; Enter with HL pointing to the register. HL is maintained.
|
|
;
|
|
qregout:ld a,(quiet)
|
|
or a
|
|
ret nz
|
|
regout: call print
|
|
db ' Reg',' '+80h
|
|
ld de,z3msg+30h ; Register 0
|
|
sbc hl,de ; Register number in hl
|
|
ld a,l
|
|
cp 32 ; A numbered register?
|
|
jr c,rego0 ; Yep
|
|
call print
|
|
db ' ','E'+80h
|
|
jr rego1 ; Report
|
|
|
|
rego0: push hl
|
|
push de
|
|
ld b,0 ; Suppress zeros
|
|
call decdsp2 ; Report register number
|
|
pop de
|
|
pop hl
|
|
rego1: add hl,de ; Hl points to register again
|
|
call print
|
|
db ' =',' '+80h
|
|
ld l,(hl)
|
|
xor a
|
|
ld h,a
|
|
ld b,a ; Suppress leading zeros
|
|
jp decdsp3 ; Display value
|
|
|
|
; Evaluate decimal string at DE to binary in B
|
|
|
|
de2bin: ld b,0 ; Init value to zero
|
|
de2b: ld a,(de) ; Get this digit
|
|
inc de ; Pt to next
|
|
sub '0' ; Convert to binary
|
|
ret c ; A space, finished
|
|
cp 10 ; Range?
|
|
ret nc ; Not decimal, finished
|
|
ld c,a ; Digit in c
|
|
ld a,b ; Multiply old by 10
|
|
add a,a ; *2
|
|
add a,a ; *4
|
|
add a,b ; *5
|
|
add a,a ; *10
|
|
add a,c ; Add in new digit
|
|
ld b,a ; Result in b
|
|
jr de2b ; Again
|
|
|
|
; Set HL to point to memory register whose index is pted to by HL
|
|
; On input, A contains register char
|
|
; On output, HL = address of memory register (reg 0 assumed if error)
|
|
|
|
regptr: ld hl,z3msg+6 ; The e register
|
|
cp 'E'
|
|
ret z
|
|
push de
|
|
call de2bin ; Get register number in b
|
|
pop de
|
|
ld a,b
|
|
cp 32 ; Range 0-31
|
|
ld a,0
|
|
jr nc,regp1 ; Out of range, use 0
|
|
ld a,b ; Value in a
|
|
regp1: ld hl,z3msg+30h ; Pt to memory registers
|
|
add a,l ; Pt to proper register
|
|
ld l,a
|
|
ret ; No chance of crossing page boundary
|
|
|
|
; End RCPREG.LIB
|
|
|