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
/
A-R
/
MU313.LBR
/
MU313.ZZ0
/
MU313.Z80
Wrap
Text File
|
2000-06-30
|
23KB
|
1,219 lines
; Program: MU3
; Author: Richard Conn
; Version: 1.0
; Date: 30 June 84
; Previous Versions: None
;
; Version 1.3
; New commands:
; Byte Fill - B <start adr, end adr, byte>
; Move Mem - M <start adr, end adr, dest adr>
; Find - F <string>
; String is same syntax as POKE. Search is forward.
; Successful find is record aligned with ">" at string.
; Rpt Find - R Next occurrence of previously defined string.
; (Bug - <string> is also found within MU3 itself.)
; Place Mark - P Sets marker to current record. (Default = entry adr)
; Quick Mark - Q Return to marker set with P
; Stack internal to allow examination of ZCPR3 external stack.
; Minor additional screen display clean up.
; - Rob Friefeld, 5/13/88
;
; Version 1.2
; Commands to move forward and backward changed to any characters from the
; sets <,- and >.+. Many improvements in screen display (such as clearing
; garbage before reading input, making compatible with reverse video terminals)
; Converted to type-3 environment.
; - Jay Sage, 8/21/87
;
; Commands to move forward and backward changed from '+' and '-'
; to ".' and ',' respectively. Being unshifted keys these seem
; easier and conform more to recent ZCPR3 utilities.
; - Rick Charnes, 8/9/87
;
vers equ 13
z3env equ 0fe00h
;
; MU3 is the ZCPR3 Memory Utility. It allows the user to display
; blocks of memory, edit them, and perform general memory-oriented
; manipulation. See the file MU3.HLP for usage details.
;
;
; General Equates
;
bs equ 08h
cr equ 0dh
lf equ 0ah
fcb equ 5ch
dim equ 1 ;goto standout mode
bright equ 2 ;exit standout mode
EOLCH EQU 0 ;END OF LINE CHAR
SEPCH EQU ',' ;SEPARATOR CHAR
EROW EQU 6 ;FIRST ROW OF EDITOR DISPLAY
ECOL EQU 4 ;FIRST COL OF EDITOR DISPLAY
ECOLC EQU ECOL+16*3+8 ;FIRST COL OF EDITOR CHAR DISPLAY
ECURS EQU '>' ;EDITOR CURSOR
PRROW EQU 22 ;PROMPT ROW
PRCOL EQU 10 ;PROMPT COLUMN
PRCOLI EQU PRCOL+15 ;PROMPT INPUT COL
ERROW EQU 23 ;ERROR MESSAGE ROW
ERCOL EQU 15 ;ERROR MESSAGE COLUMN
;
; SYSLIB/Z3LIB/VLIB Externals
;
.request vlib,z3lib,syslib
ext z3vinit,tinit,envptr,codend,putcl
ext cls,gotoxy,ereol,at,vprint,stndout
ext cout,crlf,cin,caps
ext bline,sksp
ext phl4hc,pa2hc,phlfdc
;
; Environment Definition
;
if z3env ne 0
;
; External ZCPR3 Environment Descriptor
;
mu3org:
jp start
db 'Z3ENV' ;This is a ZCPR3 Utility
db 3 ;External Environment Descriptor, Type-3
z3eadr:
dw z3env
dw mu3org
start:
ld hl,(z3eadr) ;pt to ZCPR3 environment
;
else
;
; Internal ZCPR3 Environment Descriptor
;
MACLIB Z3BASE.LIB
MACLIB SYSENV.LIB
z3eadr:
jp start
SYSENV
start:
ld hl,z3eadr ;pt to ZCPR3 environment
endif
;
; Start of Program -- Initialize ZCPR3 Environment
;
ld (stksav),sp ;use internal stack rdf
ld sp,mu3stk
call z3vinit ;initialize the ZCPR3 Env and the VLIB Env
call tinit ; initialize the terminal jww
;
; DEFINE FREE SPACE
;
CALL CODEND ;DEUERMINE ADDRESS
LD (HL),126 ;126 CHARS INPUT ALLOWED
LD (BUFFER),HL ;SET PTR
;
; SET UP ARROW KEYS
;
LD HL,(ENVPTR) ;PT TO ENVIRONMENT DESCRIPTOR
LD DE,80H+10H ;PT TO ARROW KEY INFO
ADD HL,DE
LD DE,EDCURT ;PT TO CURSOR TABLE
LD B,4 ;4 ARROW KEYS
ARROW:
LD A,(HL) ;GET CHAR
LD (DE),A ;STORE CHAR
INC HL ;PT TO NEXT
INC DE ;PT TO NEXT ENTRY
INC DE
INC DE
DEC B ;COUNT DOWN
JP NZ,ARROW
;
; Check for Command Line Parameter
;
ld hl,fcb+1 ;pt to first char
ld a,(hl) ;get char
cp ' ' ;no param?
jp nz,pcheck
ld hl,(envptr) ;pt to environment descriptor
jp mu3
;
; We have a parameter
;
pcheck:
cp '/' ;help?
jp z,help
call hexin ;convert to binary
ex de,hl ;HL=value
jp mu3
;
; Print help message
;
help:
call vprint
db cr,lf,'Syntax:'
db cr,lf,' MU3 <-- Invoke MU3 at Env Desc#'
db cr,lf,' MU3 <hex adr> <-- Invoke MU3 at Address'
db 0
ret
;
; Erase to EOL
; If fct not supported, send out B spaces and B backspaces
;
vereol:
call ereol ;try erase
ret nz
push bc ;save B
ld a,' ' ;send spaces
call vereol1
pop bc ;get B
ld a,bs ;send backspaces
vereol1:
call cout ;send char in A
dec b
jp nz,vereol1
ret
;
; Clear Screen
; If fct not supported, write 24 CRLFs
;
vcls:
call cls ;try clear
ret nz
push bc ;save B
ld b,24 ;count
vcls1:
call crlf
dec b
jp nz,vcls1
pop bc
ret
;
; Run MU3
; HL contains starting address
;
mu3:
LD (BLOCK),HL ;SAVE PTR TO BLOCK
ld (edmark),hl ;Save ptr to place marker rdf
;
; REFRESH EDIT SCREEN
;
EDIT0:
CALL VCLS ;NEW SCREEN
CALL AT
DB 2,18 ;ROW 2, COL 18
CALL VPRINT ;BANNER
DB 'MU3 Memory Editor, Version '
DB (VERS/10)+'0','.',(VERS MOD 10)+'0',0
CALL AT
DB 3,24
CALL VPRINT
DB '(Loaded at ',0
LD HL,MU3ORG
CALL PHL4HC
CALL VPRINT
DB 'H)',0
CALL AT ;POSITION FOR VALUE TEXT
DB 2,62
CALL VPRINT
DB 'Byte at Cursor',0
CALL AT
DB 3,61
CALL VPRINT
DB DIM,' HEX ',BRIGHT,' ',DIM,' CHAR ',BRIGHT,0
LD H,EROW+9 ;POSITION FOR COMMAND DISPLAY
LD L,1
CALL GOTOXY ;POSITION CURSOR
CALL VPRINT ;PRINT COMMAND SUMMARY
DB ' -- Movement --'
DB ' ------------------------ Operation --------------------------',CR,LF
DB ' ^E '
DB 'A ',DIM,' Enter Address ',BRIGHT
DB ' B ',dim,' Byte Fill ',BRIGHT
DB ' >.+ ',DIM,' Next Block ',BRIGHT,CR,LF
DB ' ^ '
DB 'H ',DIM,' Hex Calculator ',BRIGHT
DB ' M ',dim,' Move Memory',BRIGHT
DB ' <,- ',DIM,' Prev Block ',BRIGHT,CR,LF
DB ' ^S <-+-> ^D '
DB 'N ',DIM,' Enter Hex Numbers ',BRIGHT
DB ' F ',dim,' Find ',BRIGHT
DB ' ^R ',DIM,' Replot Screen ',BRIGHT,CR,LF
DB ' v '
DB 'T ',DIM,' Enter Text ',BRIGHT
DB ' R ',dim,' Rpt Find ',BRIGHT
DB ' ^C ',DIM,' Exit MU3 ',BRIGHT,CR,LF
DB ' ^X '
DB 'C ',DIM,' Enter Command Line',BRIGHT
DB ' P-Q ',dim,' Place-Quick',BRIGHT
DB ' X ',DIM,' eXit MU3 ',BRIGHT
DB 0
;
; REENTER MU3 WITH PTRS RESET
;
MU3R:
XOR A ;A=0
LD (EINDEX),A ;SET INDEX TO 0 (FIRST ELEMENT)
LD (EDERR),A ;SET NO PREVIOUS ERROR
CALL EDPLOT ;PLOT BUFFER DATA
;
; INPUT EDITOR COMMAND
;
EDITCMD:
CALL EDERCL ;CLEAR EDITOR INVALID COMMAND MESSAGE
EDITCMD1:
CALL PRMSG ;POSITION AT PROMPT MESSAGE
DB DIM,' MU3 Command? ',BRIGHT,0
CALL EREOL ;CLEAR OUT OLD COMMAND
CALL PRINP ;POSITION AT PROMPT INPUT
DB 0
CALL CIN ;GET CHAR
CALL CAPS ;CAPITALIZE
LD B,A ;COMMAND IN B
LD HL,EDCURT ;PROCESS CURSOR COMMANDS FIRST
CALL CMD ;PROCESS COMMAND
LD HL,ECMDTBL ;EDITOR COMMAND TABLE
CALL CMD ;PROCESS COMMAND
LD A,0FFH ;SET ERROR FLAG
LD (EDERR),A
CALL ERMSG ;ERROR MESSAGE
DB 'Invalid Command',0
JP EDITCMD1
;
; Position at Prompt Message and Print it
;
PRMSG:
CALL AT ;POSITION
DB PRROW,PRCOL
JP VPRINT ;PRINT IT
;
; Position at Prompt Input and Print Prompt
;
PRINP:
CALL AT ;POSITION
DB PRROW,PRCOLI
JP VPRINT ;PRINT IT
;
; Position at Error Message and Print It
;
ERMSG:
CALL AT ;POSITION
DB ERROW,ERCOL
JP VPRINT ;PRINT IT
;
;INPUT ERROR
;
WHAT:
LD A,0FFH ;SET ERROR FLAG
LD (EDERR),A
CALL ERMSG
DB 'Value Error',0
JP EDITCMD1
;
;Command Table Search and Execute
;
CMD:
LD A,(HL) ;CHECK FOR END OF TABLE
OR A
RET Z ;COMMAND NOT FOUND
CP B ;MATCH?
JP Z,CMDRUN
INC HL ;SKIP TO NEXT ENTRY IN TABLE
INC HL
INC HL
JP CMD
;
;RUN COMMAND
;
CMDRUN:
INC HL ;PT TO LOW ADDRESS
LD E,(HL)
INC HL ;PT TO HIGH ADDRESS
LD D,(HL)
EX DE,HL
POP AF ;CLEAR STACK
JP (HL) ;RUN ROUTINE
;
;PLOT BUFFER DATA
;
EDPLOT:
LD H,EROW-1 ;SET ROW
LD L,ECOL-1 ;SET COLUMN
CALL GOTOXY ;POSITION CURSOR
CALL VPRINT
DB DIM
DB ' 0 1 2 3 4 5 6 7 8 9 A B C D E F'
DB BRIGHT,0
INC H ;NEXT ROW
CALL GOTOXY ;POSITION CURSOR
EX DE,HL ;POSITION IN DE
LD HL,(BLOCK) ;PT TO DATA
LD B,8 ;8 LINES
;
;Print Next Line on Screen
;
EDIT00:
CALL VPRINT
DB DIM,':',0
LD A,H ;OUTPUT ADDRESS
CALL PA2HC
LD A,L
CALL PA2HC
CALL VPRINT
DB ':',BRIGHT,' ',0
LD C,16 ;16 ELEMENTS
EDIT01:
LD A,(HL) ;GET BYTE
CALL PA2HC ;PRINT AS HEX
CALL SPACE ;PRINT 1 SPACE
INC HL ;PT TO NEXT
DEC C ;COUNT DOWN
JP NZ,EDIT01
EX DE,HL ;POSITION AGAIN
INC H ;NEXT ROW
CALL GOTOXY
EX DE,HL
DEC B ;COUNT DOWN
JP NZ,EDIT00
LD H,EROW ;RESET ROW
LD L,ECOLC ;RESET COL
CALL GOTOXY ;POSITION CURSOR
EX DE,HL ;POSITION IN DE
LD HL,(BLOCK) ;PT TO DATA
LD B,8 ;8 LINES
EDIT02:
CALL BAR ;PRINT BAR
LD C,16 ;16 ELEMENTS
EDIT03:
LD A,(HL) ;GET BYTE
AND 7FH ;MASK MSB
CP 7FH ;DON'T PRINT 7FH
JP Z,EDIT7F
CP ' ' ;SPACE OR MORE?
JP NC,EDIT04
EDIT7F:
LD A,'.' ;PRINT DOT
EDIT04:
CALL COUT ;PRINT BYTE
INC HL ;PT TO NEXT
DEC C ;COUNT DOWN
JP NZ,EDIT03
CALL BAR ;PRINT ENDING BAR
EX DE,HL ;POSITION AGAIN
INC H ;NEXT ROW
CALL GOTOXY
EX DE,HL
DEC B ;COUNT DOWN
JP NZ,EDIT02
CALL EDCUR ;POSITION CURSOR
RET
;
;EDITOR COMMAND TABLE
;
ECMDTBL:
DB CR ;NOP
DW EDITCMD
DB 'C'-'@' ;^C = EXIT MU3
DW EDCC
DB 'X' ; X = EXIT MU3
DW EDCC
DB 'R'-'@' ;^R = REFRESH
DW EDIT0
DB 'E'-'@' ;^E=UP
DW EDUP
DB 'X'-'@' ;^X=DOWN
DW EDDOWN
DB 'D'-'@' ;^D=RIGHT
DW EDRIGHT
DB 'S'-'@' ;^S=LEFT
DW EDLEFT
DB ' ' ;NOP
DW EDITCMD
DB '+' ;ADVANCE
DW EDITPLUS
DB '.'
DW EDITPLUS
DB '>'
DW EDITPLUS
DB '-' ;BACKUP
DW EDITMINUS
DB ','
DW EDITMINUS
DB '<'
DW EDITMINUS
DB 'A' ;ADDRESS
DW EDITADR
DB 'C' ;COMMAND LINE
DW EDITCL
DB 'H' ;HEX CALC
DW EDITCALC
DB 'N' ;CHANGE NUMBERS
DW EDITHEX
DB 'T' ;CHANGE TEXT
DW EDITALP
;new commands rdf
db 'B' ;BYTE FILL
dw editfill
db 'M' ;MOVE MEM
dw editmove
db 'P' ;PLACE MARK
dw editplace
db 'Q' ;QUICK TO MARK
dw editmark
db 'F' ;FIND
dw edfind
db 'R' ;REPEAT FIND
dw edrefind
DB 0 ;END OF TABLE
;
; ARROW KEY DEFINITONS FROM TCAP
;
EDCURT:
DB 0 ;0 INDICATES NO ARROW KEYS
DW EDUP
DB 0
DW EDDOWN
DB 0
DW EDRIGHT
DB 0
DW EDLEFT
DB 0 ;END OF TABLE
;
;Enter Command Line
;
EDITCL:
CALL EDERCL ;CLEAR ERROR LINE
CALL CRLF ;NEW LINE
CALL VPRINT ;PROMPT INPUT
DB 'Command Line? ',0
CALL EREOL ;CLEAR OUT GARBAGE ON LINE
CALL RDBUF ;INPUT TEXT
CALL PUTCL ;STORE COMMAND LINE
ld sp,(stksav) ;restore incoming pointer rdf
JP CRLF ;NEW LINE
;
;Enter ASCII Chars
;
EDITALP:
CALL EDERCL ;CLEAR ERROR LINE
CALL PRINP ;PROMPT INPUT
DB DIM,' Enter Text (<hh> for Hex) ',BRIGHT
DB CR,LF,' --> ',0
CALL EREOL ;CLEAR OUT ANY GARBAGE ON LINE
CALL RDBUF ;INPUT TEXT WITHOUT PROMPT
CALL EDPRCL ;CLEAR PROMPT LINE
LD A,(EINDEX) ;PT TO POSITION
EX DE,HL
LD HL,(BLOCK) ;COMPUTE OFFSET
EX DE,HL
ADD a,E
LD E,A
LD A,D
ADC 0
LD D,A ;DE PTS TO BYTE, HL PTS TO TEXT
EDITA1:
LD A,(HL) ;GET CHAR
CP EOLCH ;EOL?
JP Z,EDITA2 ;REFRESH SCREEN
CALL GETVAL ;GET ASCII OR <HEX> VALUE
LD (DE),A ;UPDATE BYTE
INC HL ;PT TO NEXT INPUT CHAR
INC E ;PT TO NEXT BUFFER BYTE
JP NZ,EDITA1
EDITA2:
CALL EDPLOT ;REPLOT
JP EDITCMD1 ;DONE-REFRESH SCREEN
;
;Calculate Sum and Differences
;
EDITCALC:
CALL EDERCL ;CLEAR ERROR LINE
CALL PRINP ;PROMPT INPUT
DB DIM,' Enter Two Hex Numbers: ',BRIGHT,' ',0
CALL RDBUF ;INPUT TEXT
CALL EDPRCL ;CLEAR PROMPT LINE
CALL SKSP ;SKIP TO NON-SPACE
LD A,(HL) ;ANY INPUT?
OR A ;0=NO
JP Z,EDITCMD1
CALL HEXIN ;EVALUATE FIRST NUMBER
CALL SKSP ;SKIP TO 2ND NUMBER
PUSH DE ;SAVE FIRST NUMBER
CALL HEXIN ;EVALUATE 2ND NUMBER
POP HL ;GET FIRST NUMBER
CALL ERMSG ;PRINT ERROR MESSAGE
DB 0
CALL PHL4HC ;PRINT FIRST NUMBER
CALL VPRINT
DB ' and ',0
EX DE,HL
CALL PHL4HC ;PRINT 2ND NUMBER
EX DE,HL
CALL VPRINT
DB ' ',DIM,' Sum = ',BRIGHT,' ',0
PUSH HL
ADD HL,DE
CALL NUMOUT
POP HL
CALL VPRINT
DB ' ',DIM,' Diff = ',BRIGHT,' ',0
LD A,L ;HL=HL-DE
SUB a,E
LD L,A
LD A,H
SBC a,D
LD H,A
CALL NUMOUT
JP EDITCMD1
;
;Output number in HL in Hex and Decimal
;
NUMOUT:
CALL PHL4HC ;HEX
CALL VPRINT
DB ' (',0
CALL PHLFDC ;DECIMAL FLOATING
LD A,')' ;CLOSE PAREN
JP COUT
;
;Enter Numbers
;
EDITHEX:
CALL EDERCL ;CLEAR ERROR LINE
CALL PRINP ;PROMPT INPUT
DB DIM,' Enter Hex Numbers (#nn for Dec) '
DB BRIGHT
DB CR,LF,' --> ',0
CALL EREOL ;CLEAR OUT ANY GARBAGE ON LINE
CALL RDBUF ;INPUT TEXT WITHOUT PROMPT
CALL EDPRCL ;CLEAR PROMPT LINE
LD A,(EINDEX) ;PT TO POSITION
EX DE,HL
LD HL,(BLOCK) ;COMPUTE OFFSET
EX DE,HL
ADD a,E
LD E,A
LD A,D
ADC 0
LD D,A ;DE PTS TO BYTE, HL PTS TO TEXT
EDITH1:
LD A,(HL) ;GET HEX DIGIT
CP EOLCH ;EOL?
JP Z,EDITA2 ;REFRESH SCREEN
CP ' ' ;SKIP SPACES
JP NZ,EDITH2
INC HL ;SKIP SPACE
JP EDITH1
EDITH2:
PUSH DE ;SAVE PTR
CALL HEXIN ;GET VALUE AND POSITION HL
LD A,E ;... IN A
POP DE ;GET PTR
LD (DE),A ;PUT BYTE
INC E ;ADVANCE TO NEXT BYTE
JP NZ,EDITH1
JP EDITA2 ;DONE-REFRESH
;
;Clear Editor Invalid Command Message
;
EDERCL:
LD A,(EDERR) ;PREVIOUS ERROR?
OR A ;0=NO
RET Z
XOR A ;CLEAR FLAG
LD (EDERR),A
CALL ERMSG ;CLEAR ERROR MESSAGE
DB 0
LD B,40 ;40 CHARS MAX
JP VEREOL
;
;CLEAR PROMPT LINE
;
EDPRCL:
CALL PRINP ;PROMPT LINE
DB 0
LD B,40 ;40 POSITIONS
CALL VEREOL ;CLEAR TO EOL OR 40 CHARS
CALL AT ;USER INPUT
DB ERROW,1
LD B,79 ;79 POSITIONS
JP VEREOL
;
;Input Address
;
EDITADR:
call edercl
call edprcl
CALL prinp
DB dim,' Address? ',bright,' ',0
CALL RDBUF ;GET USER INPUT
CALL SKSP ;SKIP LEADING SPACES
LD A,(HL) ;EMPTY LINE?
OR A
JP Z,MU3R
CALL HEXIN ;CONVERT FROM HEX
EX DE,HL ;HL = ADDRESS
LD (BLOCK),HL
JP MU3R ;REENTER
;
;Fill memory (rdf)
;
editfill:
call edercl
call prinp
db dim,' Fill <S E Val> ',bright,' ',0
call rdbuf ; Input numbers
call edprcl ; Clear prompt
call sksp
ld a,(hl) ; Any input?
or a
jp z,editcmd1 ; No
call hexin ; Get the three numbers
call sksp
push de ; Save on stack
call hexin
call sksp
push de ; Save on stack
call hexin
push de ; Save on stack
pop bc ; BC = byte
pop hl ; HL = end
pop de ; DE = start
xor a
sbc hl,de ; HL = end - start
jp c,what ; Error: end before start
ex de,hl ; HL = start, DE = size of block
editf1: ld (hl),c ; Do the fill
inc hl
ld a,d
or e
jp z,edita2 ; Replot on exit
dec de
jr editf1
;
;Move memory (rdf)
;
editmove:
call edercl
call prinp
db dim,' Move <S E D> ',bright,' ',0
call rdbuf ; Input numbers
call edprcl ; Clear prompt
call sksp
ld a,(hl) ; Any input?
or a
jp z,editcmd1 ; No
call hexin ; Get the three numbers
call sksp
push de
call hexin
call sksp
push de
call hexin ; DE = dest
pop hl ; HL = end
pop bc ; BC = start
xor a ; Compute block length
sbc hl,bc
jp c,what ; Error: end before start
push hl ; Swap HL,BC
push bc
pop hl ; HL = start
pop bc ; BC = block size
push hl ; Head move or tail move?
xor a
sbc hl,de ; Start - dest
pop hl
jr c,editm1 ; Tail move
inc bc ; Head move, BC = # bytes to move
ldir
jp edita2
editm1:
add hl,bc ; Add length to start
ex de,hl
add hl,bc ; Add length to dest
ex de,hl
inc bc ; # bytes
lddr ; Tail move
jp edita2
;
;Mark place (rdf)
;
editplace:
call edercl
ld hl,(block)
ld (edmark),hl
call vprint
db 7,0
jp editcmd1
;
;Return to mark (rdf)
;
editmark:
call edercl
ld hl,(edmark)
ld (block),hl
jp mu3r
;
;Record align display (rdf)
;
edalign:
call edercl
ld hl,(block)
ld a,l
sub 80h
ld b,a
jr c,edal1
ld l,80h
jr edal2
edal1:
ld b,l
ld l,0
edal2:
ld (block),hl
ld a,(eindex)
add b
ld (eindex),a
call edplot
jp editcmd1
;
;Find a string (rdf)
;
; Use POKE-style input for hex and text
edfind:
CALL EDERCL ;CLEAR ERROR LINE
CALL PRINP ;PROMPT INPUT
DB DIM,' Find? ',BRIGHT,' ',0
CALL RDBUF ;INPUT TEXT
CALL EDPRCL ;CLEAR PROMPT LINE
CALL SKSP ;SKIP TO NON-SPACE
LD A,(HL) ;ANY INPUT?
OR A ;0=NO
JP Z,EDITCMD1
;
; TRANSFER STRING TO FIND BUFFER, WITH HEX CONVERSION
; (Lifted from rcpiom.lib with mods)
; HL->first byte
poke:
ld b,0 ; Byte counter
ld de,findbuf+2
; Loop for storing hex values sequentially via poke code
; de -> destination address
poke1:
call sksp ; Skip to non-blank
ld a,(hl)
or a
jr z,pokex ; Done
cp '"' ; Quoted text?
jr z,poke2
inc b ; Inc arg counter
push de ; Save address
call hexin ; Get number (on err, rets directly to EDITCMD)
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:
inc hl ; Pt to next char
poke3:
ld a,(hl) ; Get next char
or a ; Done?
jr z,pokex
ld (de),a ; Put char
inc b
inc hl ; Pt to next
inc de
jr poke3
pokex:
ld a,b
ld (findbuf+1),a ; Store byte counter
edrefind:
call find00 ; Repeat find entry
jp nz,edalign
call ermsg ;No luck on Z
db 'String Not Found',0
LD A,0FFH ;SET ERROR FLAG
LD (EDERR),A
jp editcmd1
; Do the string matching. Return NZ = Match
find00:
ld a,(findbuf+1) ; = char count
or a
ret z ; Empty
ld de,1 ; Last byte to check
ld hl,(block) ; Starting point
LD A,(EINDEX) ;PT TO BYTE AT CURSOR
ADD A,L
LD L,A
LD A,H
ADC 0
LD H,A ;HL PTS TO BYTE AT CURSOR
find01:
ld bc,findbuf+1 ; Char count
ld a,(bc)
ex af,af' ; Save char count
inc bc ; First byte to match
ld a,(bc) ; Get it
find02:
add hl,de ; Add 1 to HL, next byte to compare
jr c,find06 ; Ovfl
cp (hl)
jr nz,find02 ; Keep looking
; jp nz,find02 ; faster on Z80
find03:
ex af,af' ; First byte matched
dec a ; Dec string count
jr z,find05 ; Done
find04:
inc bc ; Check rest of string
inc hl
ex af,af' ; Save count
ld a,(bc)
cp (hl)
jr z,find03 ; Matching...
jr find01 ; Mismatch
find05:
ld bc,(findbuf) ; Found it, point to start of string
dec hl ; Char count in B
djnz $-1
inc hl
ld (block),hl ; Load new location
xor a
ld (eindex),a
or -1 ; Nz return = ok
ret
find06:
xor a ; Z return = no go
ret
;
;Advance to Next Block
;
EDITPLUS:
LD HL,(BLOCK) ;ADVANCE TO NEXT BLOCK
LD DE,128 ;128 BYTES
ADD HL,DE
LD (BLOCK),HL
CALL EDPLOT ;REPLOT DATA
JP EDITCMD
;
;Backup to Last Block
;
EDITMINUS:
LD HL,(BLOCK) ;BACKUP TO LAST BLOCK
LD DE,-128 ;128 BYTES
ADD HL,DE
LD (BLOCK),HL
CALL EDPLOT ;REPLOT DATA
JP EDITCMD
;
;Exit MU3
;
EDCC:
CALL EDERCL ;CLEAR ERROR LINE
ld sp,(stksav)
JP CRLF ;NEW LINE
;
;EDIT MOVE: UP
;
EDUP:
CALL EDCCUR ;CLEAR CURSOR
LD A,(EINDEX) ;BACKUP INDEX BY 16
SUB 16
;
;Common EDIT MOVE Routine - on input, A=new index
;
EDMOVE:
AND 7FH ;MOD 128
LD (EINDEX),A
CALL EDCUR ;SET CURSOR
JP EDITCMD
;
;EDIT MOVE: DOWN
;
EDDOWN:
CALL EDCCUR ;CLEAR CURSOR
LD A,(EINDEX) ;INCREMENT INDEX BY 16
ADD 16
JP EDMOVE ;COMMON ROUTINE
;
;EDIT MOVE: RIGHT
;
EDRIGHT:
CALL EDCCUR ;CLEAR CURSOR
LD A,(EINDEX) ;INCREMENT INDEX BY 1
INC A
JP EDMOVE ;COMMON ROUTINE
;
;EDIT MOVE: LEFT
;
EDLEFT:
CALL EDCCUR ;CLEAR CURSOR
LD A,(EINDEX) ;DECREMENT INDEX BY 1
DEC A
JP EDMOVE ;COMMON ROUTINE
;
;EDIT SUBROUTINE: EDCUR
; Position Editor Cursor at EINDEX
;EDIT SUBROUTINE: EDCCUR
; Clear Editor Cursor at EINDEX
;
EDCUR:
PUSH HL ;SAVE HL
LD C,ECURS ;CURSOR CHAR
CALL EDSETCUR
CALL AT ;UPDATE DATA
DB 3,67
LD A,(EINDEX) ;PT TO BYTE AT CURSOR
LD HL,(BLOCK)
ADD A,L
LD L,A
LD A,H
ADC 0
LD H,A ;HL PTS TO BYTE AT CURSOR
LD A,(HL) ;GET BYTE
CALL PA2HC ;PRINT AS HEX
CALL AT
DB 3,77
LD A,(HL) ;GET BYTE
POP HL ;RESTORE HL
AND 7FH ;MASK
CP 7FH ;7FH AS DOT
JP Z,EDC7F
CP ' ' ;OUTPUT CHAR OR DOT
JP NC,COUT
EDC7F:
LD A,'.' ;DOT
JP COUT
EDCCUR:
LD C,' ' ;CLEAR CURSOR
EDSETCUR:
CALL EDROW ;COMPUTE ROW
AND 0FH ;COMPUTE COL MOD 16
LD B,A ;RESULT IN B
ADD a,A ;*2
ADD a,B ;*3
ADD ECOL+6 ;ADD IN COL
DEC A ;SUBTRACT 1
LD L,A ;COL POSITION SET
CALL GOTOXY ;POSITION CURSOR
LD A,C ;OUTPUT CHAR
ld (edsc1),a
cp ' '
JP z,COUT
call vprint ;show eindex in standout mode
edsc1 equ $+1
db 1,' ',2,0
ret
;
;Compute Row from EINDEX
;
EDROW:
LD A,(EINDEX) ;GET INDEX
LD B,A ;SAVE IN B
RRCA ;DIVIDE BY 16
RRCA
RRCA
RRCA
AND 0FH ;MASK FOR LSB ONLY
ADD EROW ;COMPUTE ROW
LD H,A ;ROW SET
LD A,B ;GET INDEX
RET
;
;PRINT A SPACE
;
SPACE:
LD A,' '
JP COUT
;
;PRINT AN BARISK IN REV VIDEO
;
BAR:
CALL VPRINT
DB DIM,'|',BRIGHT,0
RET
;
;Get value from input buffer
;
GETVAL:
LD A,(HL) ;GET NEXT CHAR
CP '<' ;HEX ESCAPE?
RET NZ ;NO, RETURN
;"<<" means one "<"
INC HL
LD A,(HL)
CP '<'
RET Z
;Got hex
PUSH DE
CALL HEXIN ;GET VALUE
CP '>' ;PROPER DELIM?
LD A,E ;GET VALUE
POP DE
RET Z
;
;ERROR CONDITION IN SUBROUTINE - CLEAR STACK AND FLAG ERROR
;
SERR:
POP AF ;CLEAR STACK
JP WHAT ;ERROR
;
;Input Number from Command Line -- Assume it to be Hex
; Number returned in DE
;
HEXIN:
LD DE,0 ;INIT VALUE
LD A,(HL)
CP '#' ;DECIMAL?
JP Z,HDIN ;MAKE DECIMAL
;
HINLP:
LD A,(HL) ;GET CHAR
CALL CAPS ;CAPITALIZE
CP CR ;EOL?
RET Z
CP EOLCH ;EOL?
RET Z
CP SEPCH
RET Z
CP ' ' ;SPACE?
RET Z
CP '-' ;'THRU'?
RET Z
CP '>'
RET Z
INC HL ;PT TO NEXT CHAR
CP '0' ;RANGE?
JP C,SERR
CP '9'+1 ;RANGE?
JP C,HINNUM
CP 'A' ;RANGE?
JP C,SERR
CP 'F'+1 ;RANGE?
JP NC,SERR
SUB 7 ;ADJUST FROM A-F TO 10-15
;
HINNUM:
SUB '0' ;CONVERT FROM ASCII TO BINARY
EX DE,HL
ADD HL,HL ;MULT PREVIOUS VALUE BY 16
ADD HL,HL
ADD HL,HL
ADD HL,HL
ADD a,L ;ADD IN NEW DIGIT
LD L,A
EX DE,HL
JP HINLP
;
HDIN:
INC HL ;SKIP '#'
;
;Input Number in Command Line as Decimal
; Number is returned in DE
;
DECIN:
LD DE,0
LD A,(HL) ; GET 1ST CHAR
CP '#' ; HEX?
JP NZ,DINLP
INC HL ; PT TO DIGIT
JP HINLP ; DO HEX PROCESSING
;
DINLP:
LD A,(HL) ;GET DIGIT
CALL CAPS ;CAPITALIZE
CP '0' ;RANGE?
RET C
CP '9'+1 ;RANGE?
RET NC
SUB '0' ;CONVERT TO BINARY
INC HL ;PT TO NEXT
PUSH HL
LD H,D
LD L,E
ADD HL,HL ;X2
ADD HL,HL ;X4
ADD HL,DE ;X5
ADD HL,HL ;X10
ADD a,L ;ADD IN DIGIT
LD L,A
LD A,H
ADC 0
LD H,A
EX DE,HL ;RESULT IN DE
POP HL
JP DINLP
;
; READ LINE FROM USER INTO INPUT LINE BUFFER
;
RDBUF:
LD HL,(BUFFER) ;PT TO BUFFER
XOR A ;DON'T CAPITALIZE
JP BLINE ;INPUT LINE ROUTINE
;
;EDITOR BUFFERS
;
BLOCK:
DS 2 ;ADDRESS OF CURRENT BLOCK
BUFFER:
DS 2 ;PTR TO FREE SPACE
EINDEX:
DS 1 ;INDEX ENTRY
EDERR:
DS 1 ;ERROR FLAG
EDRUN:
DS 1 ;FLAG SAYING THAT EDITOR IS RUNNING
EDMARK: DS 2 ;PLACE MARKER
FINDBUF:
DB 20 ;SEARCH STRING
DS 22
STKSAV: DS 2 ;OLD STACK POINTER
DS 48
MU3STK: DS 2
end