Trailing-Edge
-
PDP-10 Archives
-
integ_tools_tops20_v7_30-apr-86_dumper
-
tools/tvaxv2/gtvr04.mar
There are 7 other files named gtvr04.mar in the archive. Click here to see a list.
.TITLE GTVR04 - COMMAND PARSE ROUTINE
; ENTRY GTVR04
; PARAMETERS
; R0 = LENGTH INPUT
; R1 = ADDR OF INPUT
;
; STACK FOR INPUT INTERPRETER
GSILL==0 ;INPUT LENGTH
GSIADR==GSILL+4 ;ADDR INPUT
GSITR==GSIADR+4 ;NR 0F <> LEVELS ACTIVE
GSITT==GSITR+4 ;WORK AREA FOR ITERATION MAX 15
GSXLL==GSITT+15*8
INIT GTVR04
SUBL2 #GSXLL,SP
MOVL SP,R11 ;COMMAND INTERPRETER STACK AREA
MOVL R0,GSILL(R11)
CMPW #1,R0
IF. *EQ ;IMMIDIATE COMM
BISB2 #GXIN1,GSTAT
ENDIF.
MOVL R1,GSIADR(R11) ;SAVE LL + ADDR
CLRL GSITR(R11) ;NR <> LEVELS
BICB2 #GXRNG+GXVAL+GXSRCH1,GSTAT
L1:
CALLS #0,GTVR05 ;GET EXPRESSION IN GEXP1
TSTW GERRN
IF. *GTS ;ERROR DETECTED
RET
ENDIF.
MOVL GSIADR(R11),R6
DECW GSILL(R11)
BITB #GXRNG,GSTAT
IF. *ON ;RANGE PRESENT
CASEB (R6)+,#75,#45
DC1: .WORD D75-DC1 ; K
.REPEAT 12
.WORD DERRNG-DC1
.ENDR
.WORD D88-DC1 ; X
.REPEAT 18
.WORD DERRNG-DC1
.ENDR
.WORD D75-DC1 ; k
.REPEAT 12
.WORD DERRNG-DC1
.ENDR
.WORD D88-DC1 ; x
DERRNG: MOVW #21,GERRN
BICB2 #GXRNG,GSTAT
RET
ENDIF.
BITB #GXVAL,GSTAT
IF. *ON
BICB2 #GXVAL,GSTAT
CASEB (R6)+,#27,#95
DC2: .WORD L2-DC2 ;ESCAPE
.REPEAT 30
.WORD DERVAL-DC2
.ENDR
.WORD D58-DC2 ;:
.WORD D59X-DC2 ; ;
.WORD D60-DC2 ; <
.WORD D61-DC2 ; =
.WORD DERVAL-DC2 ;>
.WORD DERVAL-DC2 ; ?
.WORD DERVAL-DC2 ; @
.WORD D65X-DC2 ; A
.WORD DERVAL-DC2 ; B
.WORD D67-DC2 ; C
.WORD D68-DC2 ; D
.WORD D69-DC2 ; E
.WORD DERVAL-DC2 ; F
.WORD DERVAL-DC2 ; G
.WORD DERVAL-DC2 ; H
.WORD D73X-DC2 ; I
.WORD D74-DC2 ; J
.WORD D75-DC2 ; K
.WORD D76-DC2 ; L
.WORD D77-DC2 ; M
.WORD D78-DC2 ;N
.WORD DERVAL-DC2 ; O
.WORD DERVAL-DC2 ; P
.WORD DERVAL-DC2 ; Q
.WORD D82-DC2 ; R
.WORD D83-DC2 ; S
.WORD D84-DC2 ; T
.WORD D85-DC2 ; u
.WORD DERVAL-DC2 ; V
.WORD DERVAL-DC2 ; W
.WORD D88-DC2 ; X
.WORD DERVAL-DC2 ; Y
.WORD DERVAL-DC2 ; Z
.WORD DERVAL-DC2 ; [
.WORD D92-DC2 ; \
.WORD DERVAL-DC2 ; ]
.WORD DERVAL-DC2 ; ^
.WORD DERVAL-DC2 ; _
.WORD DERVAL-DC2 ; '
.WORD D65X-DC2 ; a
.WORD DERVAL-DC2 ; b
.WORD D67-DC2 ; c
.WORD D68-DC2 ; d
.WORD D69-DC2 ; e
.WORD DERVAL-DC2 ; f
.WORD DERVAL-DC2 ; g
.WORD DERVAL-DC2 ; h
.WORD D73X-DC2 ; i
.WORD D74-DC2 ; j
.WORD D75-DC2 ; k
.WORD D76-DC2 ; l
.WORD D77-DC2 ; m
.WORD D78-DC2 ; n
.WORD DERVAL-DC2 ; o
.WORD DERVAL-DC2 ; p
.WORD DERVAL-DC2 ; q
.WORD D82-DC2 ; r
.WORD D83-DC2 ; s
.WORD D84-DC2 ; t
.WORD D85-DC2 ; u
.WORD DERVAL-DC2 ; v
.WORD DERVAL-DC2 ; w
.WORD D88-DC2 ; x
.WORD DERVAL-DC2 ; y
.WORD DERVAL-DC2 ; z
DERVAL: MOVW #25,GERRN
RET
ENDIF.
CASEB (R6)+,#8,#120
DC: .WORD D8-DC ;BS
.WORD D9-DC ;TAB
.WORD D10-DC ;LF
.WORD DERR-DC
.WORD D12-DC ;^L
.WORD L2-DC ;CR SKIP IT
.REPEAT 10
.WORD DERR-DC ;SPECIAL ^ CHAR
.ENDR
.WORD D24-DC ;^X
.WORD DERR-DC,DERR-DC
.WORD L2-DC ; ESC , SKIP IT
.REPEAT 4
.WORD DERR-DC
.ENDR
.WORD D32-DC ;SPACE
.WORD D33-DC ;! LABEL
.WORD D34-DC ;"
.WORD DERR-DC ;# EXPR
.WORD DERR-DC ;36 - $
.WORD DERR-DC ;% EXP
.WORD DERR-DC ;& EXP
.WORD D39-DC ;'
.WORD DERR-DC,DERR-DC,DERR-DC,DERR-DC ;( ) * + EXP
.WORD DERR-DC ;,
.BLKW 13 ;- . / 0-9 EXP
.WORD D58-DC ;:
.WORD D59-DC ; ;
.WORD D60X-DC ; <
.WORD DERR-DC ; =
.WORD D62-DC ; >
.WORD D63-DC ; ?
.WORD DERR-DC ; @ EXP
.WORD D65-DC ; A
.WORD DERR-DC ; B EXP
.WORD D67-DC ; C
.WORD D68-DC ; D
.WORD D69X-DC ; E
.WORD DERR-DC ; F EXP
.WORD D71-DC ; G
.WORD DERR-DC ; H
.WORD D73-DC ; I
.WORD D74X-DC ; J
.WORD D75-DC ;K
.WORD D76-DC ;L
.WORD D77-DC ;M
.WORD D78-DC ;N
.WORD D79-DC ;O
.WORD D80-DC ;P
.WORD DERR-DC ;Q EXP
.WORD D82-DC ;R
.WORD D83-DC ;S
.WORD D84-DC ;T
.WORD DERR-DC ;U
.WORD DERR-DC ;V
.WORD D87-DC ;W
.WORD D88-DC ;X
.WORD D89-DC ;Y
.WORD DERR-DC ;Z EXP
.WORD D91-DC ;[
.WORD DERR-DC ;\
.WORD D93-DC ;]
.WORD D91-DC ;^
.WORD D91-DC ;_
.WORD D91-DC ;'
.WORD D65-DC ; a
.WORD DERR-DC ; b EXP
.WORD D67-DC ; c
.WORD D68-DC ; d
.WORD D69X-DC ; e
.WORD DERR-DC ; f EXP
.WORD D71-DC ; g
.WORD DERR-DC ; h
.WORD D73-DC ; i
.WORD D74X-DC ; j
.WORD D75-DC ; k
.WORD D76-DC ; l
.WORD D77-DC ; m
.WORD D78-DC ; n
.WORD D79-DC ; o
.WORD D80-DC ; p
.WORD DERR-DC ; q EXP
.WORD D82-DC ; r
.WORD D83-DC ; s
.WORD D84-DC ; t
.WORD DERR-DC ; u
.WORD DERR-DC ; v
.WORD D87-DC ; w
.WORD D88-DC ; x
.WORD D89-DC ; y
.WORD DERR-DC ; z EXP
.REPEAT 5
.WORD DERR-DC ;123-127
.ENDR
.WORD L2-DC ;END OF LINE SKIP IT
DERR: MOVW #8,GERRN
RET
L2: BITB #GXTERM,GSTAT
IF. *ON ;ABORT
MOVW #24,GERRN
RET
ENDIF.
TSTW GSILL(R11)
IF. *GTS ;NOT END OF INPUT
MOVL R6,GSIADR(R11)
BRW L1
ENDIF.
TSTL GSITR(R11)
IF. *NE ;<> ACTIVE
MOVW #12,GERRN
ENDIF.
RET
;
.PAGE
D8: ;BS
MOVL #-1,GEXP1
BSBW GSHIFTLR ;BACK ONE LINE
BRW L2
;
D9: ;TAB
DECL R6
INCW GSILL(R11)
BRW D73 ;DO AN INSERT
;
D10: ;LF
MOVL #1,GEXP1
BSBW GSHIFTLR ;ADVANCE ONE LINE
BRW L2
D12: ;^L
BISB2 #GXCTLL,GSTAT
BRW L2
;
D24: ;^X
BITB #GX2SRC,GSTAT2
IF. *ON ;WAS UPPER/LOWER
BICB2 #GX2SRC,GSTAT2
MOVW #-34,GERRN
ELSE. ;WAS EXACT
BISB2 #GX2SRC,GSTAT2
MOVW #-35,GERRN
ENDIF.
BRW L2
;
D32: ;SPACE
BISB2 #GXMORE,GSTAT
BRW L2
;
D33: ;!
D34: ;"
BRW DERR7
;
D39: ;'
BRW DERR7
;
DERR7:
MOVW #7,GERRN ;NOT YET SUPPORTED
RET
D58: ; :
DECW GSILL(R11)
INCL R6
MATCHC #1,-1(R6),#W58TL,W58T
CASEB (R3),#0,#4
D58B: .WORD D58-D58B ;@
.WORD D5801-D58B ;S
.WORD D5802-D58B ;R
.WORD D5803-D58B ;K
.WORD D5804-D58B ;X
BRW DERR
D5801: ;S
BISB2 #GXSRCH1,GSTAT
BRW D83
D5802: ;R
BISB2 #GXSRCH1,GSTAT
BRW D82
D5803: ;K
BSBW CHRA
DECL R0 ;DO NOT DELETE END OF LINE
BSBW GDELR
BRW L2
D5804: ;X
BSBW CHRA
DECL R0
BRW D88X
W58T: .BYTE ^A'@',0,^A'S',1,^A's',1,^A'R',2,^A'r',2,^A'K',3,^A'k',3
.BYTE ^A'X',4,^A'x',4
W58TL=.-W58T
.BYTE 4 ;NO MATCH
;
D59X: BISB2 #GXVAL,GSTAT
D59: ;;
MOVL R6,GSIADR(R11)
BSBW GTVR03C ; DO ; COMMAND
BRW L2
;
;
D60X: ;< DEFAULT VALUE
MOVL #10000000,GEXP1 ;VERY OFTEN
D60: ;<
CMPL GSITR(R11),#15
IF. *EQ ;TOO MANY LEVELS
MOVW #5,GERRN
RET
ENDIF.
TSTL GEXP1
IF. *LES ;DO NOT EXECUTE
MOVW #37,GERRN
RET
ENDIF.
INCL GSITR(R11)
MOVL GSITR(R11),R1
ADDL2 R1,R1 ;2*8 = 16
MOVAQ GSITT(R11)[R1],R8 ;SET TABLE PTR
MOVL R6,WISTA(R8) ;START COMMAND
MOVW GSILL(R11),WILL(R8) ;REM INPUT LENGTH
MOVL GEXP1,GWINC(R8) ;MAX LOOP CNT
CLRL GWICC(R8) ;CURRENT LOOP CNT
BRW L2
D61: ;=
EDIT GEXP1,9,GERR13+2
MOVW #-13,GERRN
BRW L2
;
D62: ;>
TSTL GSITR(R11)
IF. *EQ ;NO <> ACTIVE
MOVW #6,GERRN
RET
ENDIF.
INCL GWICC(R8)
CMPL GWICC(R8),GWINC(R8)
IF. *GES ;END OF LOOP
DECL GSITR(R11)
IF. *NE ;NOT LAST LOOP
MOVL GSITR(R11),R1
ADDL2 R1,R1 ;2*8 = 16
MOVAQ GSITT(R11)[R1],R8
ENDIF.
ELSE. ;NOT END OF LOOP
MOVL WISTA(R8),R6
MOVW WILL(R8),GSILL(R11)
ENDIF.
BRW L2
WISTA=0 ;ADDR OF START COMMAND OF LOOP
WILL=4 ;LENGTH REM INPUT
GWINC==8 ;N LOOP
GWICC==12 ;CURRENT LOOP
D63: ;?
BRW DERR7
D65X: ;A + VALUE
ADDL3 GFBUFFA,GFPTR,R1
CMPL GFPTR,GHPTR
IF. *GE
ADDL2 GHCNT,R1
ENDIF.
CLRL R0
MOVB (R1),GEXP1
BISB2 #GXVAL,GSTAT ;INDICATE VALUE PRESENT
BRW D61 ;DO A = COMMAND
;
D65: ;A
BRW DERR7
D67: ;C
ADDL2 GEXP1,GFPTR
IF. *LTS ;TOO FAR BACK
CLRL GFPTR
BRW D6701
ELSE.
CMPL GFPTR,GFCNT
IF. *GT ;TOO FAR AHEAD
MOVL GFCNT,GFPTR
D6701: MOVW #20,GERRN
ENDIF.
ENDIF.
BRW L2
;
D68: ;D
MOVL GEXP1,R0 ;LL TO DELETE
IF. *LTS ;NEG
MNEGL R0,R0
SUBL3 R0,GFPTR,R1
IF. *LTS ;PASSED BEGIN OF BUFFER
MOVW #20,GERRN
RET
ENDIF.
SUBL2 R0,GFPTR ;ADJUST CURRENT PTR
ELSE.
ADDL3 GFPTR,R0,R2
CMPL R2,GFCNT
IF. *GT ;PASSED END OF BUFFER
MOVW #20,GERRN
RET
ENDIF.
ENDIF.
BSBW GDELR ;REMOVE IT
BRW L2
;
D69X:
CLRL GEXP1
D69: ;E
INCL GEXP1
MOVL GFPTR,WFPTR ;SAVE CURRENT PTR
BSBW GSHIFTLR ;TAKE POSITION
TSTL GFPTR
IF. *EQ ;AT START OF BUFFER
MOVL WFPTR,GFPTR ;RESTORE
MOVW #20,GERRN
RET
ENDIF.
TSTL R0
IF. *NE ;NOT AT END OF BUFFER
DECL GFPTR
ENDIF.
BRW L2
;
D71: ;G
MOVB (R6),R1 ;Q-REG NR
BSBW GTVR06OS ;GET ADDR LL STRING
BSBW GINSR ;INSERT IN BUFFER
INCL R6
DECW GSILL(R11)
BRW L2
;
;
D73X: ;I VALUE
MOVAB GEXP1,R1 ;ADDR STRING
MOVL #1,R0
BSBW GINSR
BRW L2
D73: ;I INSERT STRING
CMPB -2(R6),#^A'@'
IF. *EQ ;SPECIAL STRING
DECW GSILL(R11)
IF. *LTS ;WRONG SYNTAX
MOVW #32,GERRN
RET
ENDIF.
INCL R6
LOCC -1(R6),GSILL(R11),(R6)
ELSE.
LOCC #ESC,GSILL(R11),(R6)
ENDIF.
SUBW3 R0,GSILL(R11),R0
SUBW2 R0,GSILL(R11)
DECW GSILL(R11)
MOVL R6,R1 ;START OF STRING
ADDL2 R0,R6 ;ADVANCE INPUT
INCL R6
BSBW GINSRX ;INSERT STRING
BRW L2
;
D74X: ;J DEFAULT VALUE
CLRL GEXP1
D74: ;J
CMPL GEXP1,GFCNT
IF. *GT ;OUTSIDE BUFFER
MOVW #20,GERRN
RET
ENDIF.
MOVL GEXP1,GFPTR ;SET PTR
BRW L2
;
D75: ;K
BSBW CHRA ;GET R0,R1
BSBW GDELR ;DELETE FROM BUFFER
BRW L2
;
D76: ;L
BSBW GSHIFTLR ;REPOSITION
BRW L2
;
D77: ;M
MOVB (R6),R1
BSBW GTVR06OS ;GET Q-REG
SUBL2 R0,SP
MOVC3 R0,(R1),(SP) ;SAVE ON STACK
MOVL GEXP1,R2 ;LOOP COUNT
D77.1: MOVL SP,R1
SUBL3 SP,R3,R0
TSTL R2
IF. *NE ;MORE TO GO
CALLS #0,GTVR04 ;EXECUTE IT
TSTW GERRN
IF. *GTS ;SOME ERROR
RET
ENDIF.
DECL R2
BRW D77.1
ENDIF.
ADDL2 R0,SP ;RESET STACK
INCL R6
DECW GSILL(R11)
BRW L2
;
D78: ;N
D79: ;O
D80: ;P
BRW DERR7
D82: ;R
BSBW SETS1
MOVL R6,WSADD ;START SEARCH STR
BSBW SETSR
BSBW SETS2 ;SETUP SEARCH STRING
MOVL R6,WRADD ;START REPLACE STRING
BSBW SETSR
MOVW R0,WRLL
D8201: BSBW SRCHR ;SCAN
MOVZWL WSLL,R0
TSTL GEXP1
IF. *LTS ;BACKWARD
BSBW GDELR ;DELETE IT
MOVZWL WRLL,R0
MOVL WRADD,R1
MOVL GFPTR,WFPTR ;SAVE PTR
BSBW GINSRX ;INSERT IT
MOVL WFPTR,GFPTR ;RESTORE PTR
INCL GEXP1
ELSE. ;FORWARD
SUBL2 R0,GFPTR
BSBW GDELR ;DELETE IT
MOVZWL WRLL,R0
MOVL WRADD,R1
BSBW GINSRX
DECL GEXP1
ENDIF.
IF. *NE ;MORE TOO GO
BRW D8201
ENDIF.
BRW D8302
WSLL: .BLKL
WSADD: .BLKL
WRLL: .BLKW ;REPLACE STRING
WRADD: .BLKL
;
;
D83: ;S
BSBW SETS1
MOVL R6,WSADD
BSBW SETSR ;SCAN STRING
BSBW SETS2
D8301: BSBW SRCHR ;FIND IT
TSTL GEXP1
IF. *LTS ;BACKWARD
INCL GEXP1
ELSE. ;FORWARD
DECL GEXP1
ENDIF.
IF. *NE ;MORE TOO GO
BRW D8301
ENDIF.
D8302: BITB #GXSRCH1,GSTAT
IF. *ON ;SPECIAL SEARCH
BICB2 #GXSRCH1,GSTAT
BISB2 #GXVAL,GSTAT
MOVL #-1,GEXP1 ;INDICATE FOUND
ENDIF.
BRW L2
;
;
D84: ;T
BRW DERR7
D85: ;U
MOVB (R6),R1 ;QREG NR
MOVL GEXP1,R0
BSBW GTVR06IN ;SET IT
INCL R6
DECW GSILL(R11)
BRW L2
;
D86: ;V DO NOT IMPLEMENT
D87: ;W
BRW DERR7
D88: ;X
BSBW CHRA ;CHECK THE RANGE
D88X:
ADDL3 GFBUFFA,GFPTR,WDADD
ADDL2 GHCNT,WDADD ;AFTER HOLE
MOVL R0,WDLL
MOVL GFPTR,R1
BSBW GMOVHOLR ;SHIFT THE HOLE
MOVB (R6),R1
MOVAB WDADD,R0 ;DESCRIPTOR ADDR
BSBW GTVR06IS
MOVL WDLL,R0
BSBW GDELR ;DELETE FROM BUFFER
INCL R6
DECW GSILL(R11)
BRW L2
WDADD: .BLKL ;ADDRESS
WDLL: .BLKL ;LENGTH
;
D89: ;Y
CLRL GFPTR
CLRL GFCNT
CLRL GHPTR
MOVL #8192,GHCNT ;INITIAL VALUE
DECL R6
INCW GSILL(R11)
MOVL R6,GSIADR(R11)
BSBW GTVR03C ;DO YANK
BRW L2
;
D91: ;[
BRW DERR7
D92: ;\
CVTLP GEXP1,#15,WWRK1
SKPC #0,#8,(R3)
ADDL2 R0,R0
BITB #^XF0,(R1)
IF. *OFF
SUBL2 #2,R0
IF. *EQ
INCL R0
ENDIF.
ELSE.
DECL R0
ENDIF.
MOVL R0,GEXP1
CVTPS #15,WWRK1,R0,WWRK2
MOVL GEXP1,R0
CMPB #^A'+',WWRK2
IF. *EQ
MOVAB WWRK2+1,R1
ELSE.
MOVAB WWRK2,R1
INCL R0
ENDIF.
BSBW GINSR
BRW L2
WWRK1: .BLKB 8
WWRK2: .BLKB 8
;
D93: ;]
BRW DERR7
.PAGE
SETS1: ;SETUP FOR SEARCH
CMPB -2(R6),#^A'@'
IF. *NE
CMPW -3(R6),#^A'@:'
IF. *NE ;NOT SPECIAL
MOVB #ESC,WSESC
BRW SETS101
ENDIF.
ENDIF.
MOVB (R6)+,WSESC
DECW GSILL(R11)
SETS101: TSTW GSILL(R11)
IF. *LTS ;SYNTAX ERROR
MOVW #32,GERRN
RET
ENDIF.
RSB
;
;
; SCAN FOR STRING END WITH WSESC
; IN R6,GSILL(R11)
;
SETSR:
TSTW GSILL(R11)
IF. *LES ;NO MORE INPUT
CMPB WSESC,#ESC
IF. *NE ;SPECIAL SEARCH
MOVW #33,GERRN
RET ;NO ARGUMENT
ENDIF.
ENDIF.
LOCC WSESC,GSILL(R11),(R6)
SUBW3 R0,GSILL(R11),R0
CMPW R0,#256
IF. *GT ;TOO LONG
MOVW #27,GERRN
RET
ENDIF.
ADDL3 #1,R1,R6
SUBW2 R0,GSILL(R11)
DECW GSILL(R11)
RSB
;
; SET PREVIOUS SEARCH STRING IF NO STRING GIVEN
;
SETS2:
TSTW R0
IF. *EQ ;NO STRING PRESENT IN INPUT
TSTW WSLL
IF. *EQ ;NO PREVIOUS SET
MOVW #26,GERRN
RET
ENDIF.
ELSE.
MOVW R0,WSLL
MOVC3 R0,@WSADD,WSST
MOVW WSLL,R0
MOVAB WSST,R1
SETS201: LOCC #CR,R0,(R1)
IF. *NE ;CR FOUND
MOVB #GCRX,(R1)+ ;CHANGE TO END OF LINE
DECL R0
BRW SETS201
ENDIF.
ENDIF.
RSB
WSST: .BLKB 256
WSST2: .BLKB 256
WSESC: .BLKB
.PAGE
; SEARCH FOR STRING IN BUFFER
; IN WSST = STRING
; WSLL = LL STRING
; GFPTR,GEXP1
;
SRCHR: PUSHR #^M<R7,R8>
BITB #GX2SRC,GSTAT2
IF. *ON ;UPPER/LOWER
MOVTC WSLL,WSST,#0,WUTAB,WSLL,WSST2
ENDIF.
TSTL GEXP1
IF. *LTS ;BACKWARD SEARCH
CMPL GFPTR,GHPTR
IF. *GT
MOVL GFPTR,R1
BSBW GMOVHOLR ;SHIFT THE HOLE AFTER /\
ENDIF.
ADDL3 GFPTR,GFBUFFA,R7
MOVL GFCNT,R8
SUBL2 WSLL,R7
SUBL2 WSLL,R8
SRCH1: IF. *GES ;NOT PASSED START OF BUFFER
BITB #GX2SRC,GSTAT2
IF. *OFF ;EXACT
CMPB (R7),WSST
IF. *NE ;FIRST CHAR NOT OK
DECL R7
DECL R8
BRW SRCH1
ENDIF.
CMPC3 WSLL,WSST,(R7)
IF. *NE ;NO MATCH
DECL R7
DECL R8
BRW SRCH1
ENDIF.
ELSE. ;UPPER/LOWER
MOVTC #1,(R7),#0,WUTAB,#1,@GOBUFFA
CMPB @GOBUFFA,WSST2
IF. *NE
DECL R7
DECL R8
BRW SRCH1
ENDIF.
MOVTC WSLL,(R7),#0,WUTAB,WSLL,@GOBUFFA
CMPC3 WSLL,WSST2,@GOBUFFA
IF. *NE
DECL R7
DECL R8
BRW SRCH1
ENDIF.
ENDIF.
SUBL3 GFBUFFA,R7,GFPTR
ELSE.
SRCH2: BITB #GXSRCH1,GSTAT
IF. *ON ;SPECIAL SEARCH
BICB2 #GXSRCH1,GSTAT
BISB2 #GXVAL,GSTAT
CLRL GEXP1 ;NOT FOUND
POPR #^M<R7,R8> ;RELOAD
POPL R1 ;CLEAN UP STACK
BRW L2
ENDIF.
MOVW #28,GERRN ;NOT FOUND
RET
ENDIF.
ELSE. ;FORWARD
CMPL GFPTR,GHPTR
IF. *LT
MOVL GFPTR,R1
BSBW GMOVHOLR
ENDIF.
ADDL3 GFPTR,GFBUFFA,R3
ADDL2 GHCNT,R3
SUBL3 GFPTR,GFCNT,R8 ;LENGTH TO SCAN
BITB #GX2SRC,GSTAT2
IF. *OFF ;EXACT
SRCH3: CMPL R8,G64K
IF. *GT
MOVL G64K,R0
SUBL2 G64K,R8
ELSE.
MOVL R8,R0
CLRL R8
ENDIF.
MATCHC WSLL,WSST,R0,(R3)
IF. *NE ;NO MATCH
TSTL R8
IF. *NE ;NOT END OF BUFFER
SUBL3 #1,WSLL,R1
ADDL2 R1,R8 ;TAKE CARE OF
SUBL2 R1,R3 ;BORDER CASE
BRW SRCH3
ENDIF.
BRW SRCH2
ENDIF.
SUBL3 GFBUFFA,R3,GFPTR
ELSE. ;UPPER/LOWER
MOVL R3,R7
SRCH4: CMPL R8,#2048
IF. *GT
MOVL #2048,R0
SUBL2 R0,R8
ELSE.
MOVL R8,R0
CLRL R8
ENDIF.
PUSHL R0
MOVTC R0,(R7),#0,WUTAB,R0,@GOBUFFA
POPL R0
MATCHC WSLL,WSST2,R0,@GOBUFFA
IF. *NE ;NO MATCH
TSTL R8
IF. *NE ;NOT END BUFFER
ADDL2 #2048,R7
SUBL3 #1,WSLL,R1
ADDL2 R1,R8 ;THINK ABOUT
SUBL2 R1,R7 ;BORDER CASE
BRW SRCH4
ENDIF.
BRW SRCH2
ENDIF.
SUBL2 GOBUFFA,R3 ;NR OF BYTES FROM START
ADDL2 R3,R7 ;ADVANCE BUFFER PTR
SUBL3 GFBUFFA,R7,GFPTR ;FOUND POINT
ENDIF.
SUBL2 GHCNT,GFPTR ;SET PTR AT START MATCH
ENDIF.
POPR #^M<R7,R8>
RSB
.PAGE
; CHECK THE RANGE GEXP2,GEXP1
; OUT GFPTR = START BYTE NR
; R0 = LENGTH
CHRA:
BITB #GXRNG,GSTAT
IF. *ON ;RANGE PRESENT
BICB2 #GXRNG,GSTAT
CMPL GEXP2,GFCNT
IF. *GT ;PASSED END OF BUFFER
CHRA1: MOVW #23,GERRN
RET
ENDIF.
CMPL GEXP1,GFCNT
IF. *GT
BRW CHRA1
ENDIF.
SUBL3 GEXP2,GEXP1,R0
IF. *LTS ;NEG LL
BRW CHRA1
ENDIF.
MOVL GEXP2,GFPTR
ELSE. ;N LINES
BISB2 #GXRNG,GSTAT
MOVL GFPTR,WFPTR ;SAVE
BSBW GSHIFTLR
BICB2 #GXRNG,GSTAT
SUBL3 WFPTR,GFPTR,R0
IF. *LTS ;GONE BACK
MNEGL R0,R0
ELSE.
MOVL WFPTR,GFPTR
ENDIF.
ENDIF.
RSB
.PAGE
; INSERT STRING ROUTINE
; IN GFPTR
; R0 = LENGTH STRING
; R1 = ADDR STRING
;
GINSRX:: PUSHR #^M<R6,R7>
MOVL R0,R6
MOVL R1,R7
GINS1: LOCC #CR,R0,(R1)
IF. *NE ;CR FOUND
MOVB #GCRX,(R1)+
DECL R0
BRW GINS1
ENDIF.
BRW GINS2
GINSR:: PUSHR #^M<R6,R7>
MOVL R0,R6
MOVL R1,R7
GINS2: MOVL GFPTR,R1
BSBW GMOVHOLR ;POSITION HOLE OK
ADDL3 #100,R6,R0
CMPL R0,GHCNT
IF. *GT ;HOLE IS TOO SMALL
ADDL2 #4095,R0
ASHL #12,R0,R1
ASHL #-12,R1,R1 ;EXTEND MODULO 4K
BSBW GEXTHOLR
ENDIF.
ADDL3 GFPTR,GFBUFFA,R1
CMPL GFPTR,GOPTR
IF. *LT ;OUT START SHIFTED
ADDL2 R6,GOPTR
ENDIF.
ADDL2 R6,GFCNT
ADDL2 R6,GHPTR
ADDL2 R6,GFPTR
SUBL2 R6,GHCNT
MOVL R1,R3
MOVL R7,R1
GINS3: CMPL R6,G64K
IF. *GT ;MORE THAN 64K
MOVC3 G64K,(R1),(R3)
SUBL2 G64K,R6
BRW GINS3
ENDIF.
MOVC3 R6,(R1),(R3) ;INSERT STRING
POPR #^M<R6,R7>
RSB
.PAGE
;
; DELETE STRING ROUTINE
; R0 = LL TO DELETE
; GFPTR = START ADDRESS
;
GDELR::
PUSHR #^M<R6>
MOVL R0,R6
MOVL GFPTR,R1
BSBW GMOVHOLR ;SHIFT THE HOLE
ADDL2 R6,GHCNT
SUBL2 R6,GFCNT
CMPL GHPTR,GFCNT
IF. *EQ ;HOLE AT END
MOVL #8192,GHCNT
ENDIF.
ENDIF.
POPR #^M<R6>
RSB
.PAGE
; ADJUST GFPTR NR OF LINES
; GEXP1 = NR OF LINES TO ADJUST
;
; OUT R0 = 0 : END OF BUFFER WITHOUT CR
; 1 : NOT
GSHIFTLR::
PUSHR #^M<R6,R7,R8>
MOVL GFPTR,R6
MOVL GEXP1,R8
IF. *GTS ;ADVANCE
CMPL R6,GHPTR
IF. *LT ;NOT PASSED HOLE
MOVL R6,R1
BSBW GMOVHOLR ;SHIFT THE HOLE
ENDIF.
SUBL3 R6,GFCNT,R7 ;LENGTH TO SCAN
IF. *EQ ;AT END OF SCREEN
BICB2 #GXRNG,GSTAT
MOVW #20,GERRN
RET
ENDIF.
ADDL2 GHCNT,R6
ADDL3 GFBUFFA,R6,R1
SHIF0: CMPL R7,G64K
IF. *GT
MOVW G64K,R0
SUBL2 G64K,R7
ELSE.
MOVL R7,R0
CLRL R7
ENDIF.
SHIF1: LOCC #GCRX,R0,(R1)
IF. *NE ;CR FOUND
INCL R1
SUBL3 GFBUFFA,R1,R6
DECW R0
SOBGTR R8,SHIF1 ;MORE LINES TOO DO
MOVL #1,R0
ELSE.
TSTL R7
IF. *NE ;NOT END OF BUFFER
BRW SHIF0
ENDIF.
CMPL R8,#1
IF. *NE ;NOT LAST LINE
BITB #GXRNG,GSTAT
IF. *OFF
MOVW #20,GERRN
RET
ENDIF.
ENDIF.
SUBL3 GFBUFFA,R1,R6
ENDIF.
SUBL3 GHCNT,R6,GFPTR ;ADJUST /\
ELSE.
CMPL R6,GHPTR
IF. *GT ;HOLE BEFORE PTR
MOVL R6,R1
BSBW GMOVHOLR ;SHIFT THE HOLE
ENDIF.
ADDL2 GFBUFFA,R6
MOVL GFPTR,R7 ;LENGTH TO SCAN
MNEGL R8,R8
INCL R8 ;ONE MORE
SHIF2: TSTL R7
IF. *EQ ;START OF BUFFER
DECL R8
IF. *NE ;NOT FAR ENOUGH
BITB #GXRNG,GSTAT
IF. *OFF
MOVW #20,GERRN
RET
ENDIF.
ENDIF.
ELSE.
SHIF3: DECL R6
CMPB (R6),#GCRX
IF. *NE ;NO CR
SOBGTR R7,SHIF3
BRW SHIF2
ELSE. ;CR FOUND
DECL R7
SOBGTR R8,SHIF2
INCL R6
ENDIF.
ENDIF.
SUBL3 GFBUFFA,R6,GFPTR
MOVL #1,R0 ;NOT END OF BUFFER
ENDIF.
POPR #^M<R6,R7,R8>
RSB
WFPTR: .BLKL
ESC=27
CR=13
.END