Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-04 - decus/20-0108/aedith.mac
There are 2 other files named aedith.mac in the archive. Click here to see a list.
	TITLE	AEDIT
	SUBTTL	THE ASCII EDIT PACKAGE  (SEGMENTED VERSION)
	TWOSEG	400000
	RELOC	400000
;
;	THE ASCII EDIT PACKAGE
;
;				DA GORKA 24-MAR-76
;

P=17				; THE PDL USED
OPDEF	CALL[PUSHJ P,]		; CALL OP
OPDEF	RET[POPJ P,0]		; THE RETURN OP

;
;	ADIT% - ENTER THE ASCII EDIT PACKAGE WITH INITIALIZATION
;

ADIT%::	MOVEM	1,EDIT		; SAVE THE EDIT PACKET ADDRESS
	CALL	SAVE
	HRR	2,0(1)		; GET THE DATA AREA ADDRESS
	HRLI	2,(POINT 7,)	; A BYTE POINTER
	MOVEM	2,1(1)		; SAVE THE CURRENT BYTE POINTER
	MOVEM	2,3(1)		; AND THE CURRENT LINE START
	HLRZ	3,0(1)		; GET THE WC THIS IMAGE
	IMULI	3,5		; CVT TO CHARS
	MOVEM	3,2(1)		; SAVE THE CC
	HLRZ	2,0(1)		; THE WC THIS IMAGE
	MOVE	1,0(1)		; GET THE IMAGE ADDRESS
	HRLS	1		; FOR THE BLT ACW
	ADDI	2,0(1)		; THE END ADDRESS FOR THE BT
	MOVE	3,[ASCIZ "     "]
	MOVEM	3,0(1)		; CVT TO SPACES
	AOJA	1,.+1
	BLT	1,-1(2)		
	RET			; RETURN


;
;	AMSG% - COPY THE STRING UNTIL THE FIRST NULL
;

AMSG%::	CALL	SAVE		; SAVE 1 THROUGH 5
	HRLI	1,(POINT 7,)	; A BYTE POINTER
	MOVE	2,1		; FOR THE ACHAR% CALL
	ILDB	1,2		; GET THE CHAR
	JUMPE	1,AMSG		; DONE ?     YES,AMSG
	CALL	ACHAR%		; OUTPUT THE CHARACTER
	JRST	.-3		; FOR ALL
AMSG:	RET			; $E
;
;	APOS% - POSITION TO THE COLUMN SPECIFIED
;

APOS%::	CALL	SAVE		; SAVE THE REGISTERS
	IDIVI	1,5		; 1 = # OF WORDS, 2 = CHARS
	HRRZ	4,3(3)		; GET CURRENT LINE ADDRESS
	ADDI	4,0(1)		; 4 = CORRECT WORD
	HLL	4,3(3)		; GET THE BYTE DESCRIPTOR
	SKIPE	2		; A WORD BOUNDARY ?
	IBP	4		; NO - MOVE IT RIGHT
	SOJG	2,.-1
	MOVEM	4,1(3)		; SET US THERE
	RET

;
;	AFD1% - EDIT IN THE ASCII IN 1
;

AFD1%::	CALL	SAVE		; SAVE EM
	MOVE	2,[POINT 7,-1(P)]
AFD1:	MOVEI	4,5		; # OF CHARACTERS PER WORD IN ASCII
AFD10:	ILDB	1,2
	JUMPE	1,AFD11		; NULL ?     YES,IGNORE
	CALL	ACHAR%		; PUT THE CHAR AWAY
AFD11:	SOJG	4,AFD10		; REPEAT FOR ALL
	RET

;
;	AFD2% - COPY THE 2 REGISTERS OF ASCII
;

AFD2%::	CALL	SAVE
	MOVE	2,[POINT 7,-2(P)]
	CALL	AFD1		; COPY THIS WORD (AC1)
	MOVE	2,[POINT 7,-2(P)]
	JRST	AFD1		; CALL AND RETURN
;
;	ATIME% - ENTER THE CURRENT TIME
;

ATIME%:: CALL	SAVE		; SAVE THE USER
	SKIPN	1		; ANY TIME PASSED ?
	MSTIME	1,		; NO - GET SOME
	IDIVI	1,^D1000	; CVT TO SECONDS
	IDIVI	1,^D3600	; 1 = HOURS
	PUSH	P,2		; SAVE MM:SS
	MOVE	2,["0",,2]	; FIELD CHAR, FIELD WIDTH
	CALL	ADECF%		; ENTER IT AS FIXED DECIMAL
	MOVEI	1,":"		; THE COLON
	CALL	ACHAR%
	POP	P,1
	IDIVI	1,^D60		; 2 = SECONDS
	PUSH	P,2
	MOVE	2,["0",,2]
	CALL	ADECF%
	MOVEI	1,":"		; THE ":" FOR MM
	CALL	ACHAR%
	POP	P,1
	JRST	ADECF%		; CALL AND LEAVE
;
;	ADAY% - ENTER THE CURRENT DAY
;

ADAY%::	CALL	SAVE		; SAVE THE WORLD
	DATE	1,		; GET THE DATE IN DEC'S FORMAT
	IDIVI	1,^D12*^D31	; 1 = THE YEAR
	ADDI	1,^D64		; ADD ON THE BASE DATE
	PUSH	P,1
	IDIVI	2,^D31		; 2 = MONTH, 3 = DAY-1
	ADDI	3,1		; OFF BY ONE
	PUSH	P,3		; SAVE THE DAY
	MOVE	1,2		; THE MM
	MOVE	2,["0",,2]	; "0" AS FIELD, 2 WIDE
	CALL	ADECF%		; ENTER THE MONTH
	MOVEI	1,":"		; MM:DD:YY FORMAT
	CALL	ACHAR%
	POP	P,1		; GET DD
	CALL	ADECF%
	MOVEI	1,":"
	CALL	ACHAR%
	POP	P,1		; THE YY
	JRST	ADECF%
;
;	ADECV% - ENTER IN A NUMBER IN VARIABLE FORM
;

ADECV%:: CALL	SAVE		; SAVE OR REGS
	MOVEM	P,4(3)		; SAVE THE CURRENT P
	JRST	ADECF2
ADECV:	IDIVI	1,12		; CVT TO DECIMAL ONLY
	PUSH	P,2
	JUMPN	1,.-2		; MORE TO GO ?     YES,.-2
	SKIPE	1,5		; A FLAG ?
	CALL	ACHAR%
	POP	P,1		; UNWIND THE STACK
	ADDI	1,"0"		; TO ASCII
	CALL	ACHAR%		; INSERT THE CHAR
	CAME	P,4(3)		; ALL DONE ?
	JRST	.-4		; NO - REPEAT
	RET

;
;	ASIX% - EDIT OUT A SIXBIT QUANTITY - NO BLANKS !
;

ASIX%::	CALL	SAVE		; [01] SAVE REGISTERS
	MOVEI	3,6	; ONLY DO SIX CHARACTERS
	MOVE	2,[POINT 6,-1(P)]
ASIX1:	ILDB	1,2		; GET THE SIXBIT CHAR
	JUMPE	1,ASIX2		; IGNORE NULLS
	CAIL	1,'A'		; ALPHA ?
	CAILE	1,'Z'
	TRCA	1,40
	TRC	1,140
	CALL	ACHAR%		; EDIT INTO BUFFER
ASIX2:	SOJG	3,ASIX1		; REPEAT AS NEEDED
	RET			; AND RETURN
;
;	ADECF% - ENTER A NUMBER IN THE FIELD SPECIFIED
;

ADECF%:: CALL	SAVE		; ET ALL
	HLRZ	5,2		; GET POSSIBLE FIELD CHAR
	SKIPN	5		; ANY FIELD CHAR AT ALL ?
	MOVEI	5," "		; NO - ASSUME A SPACE	
	MOVEM	P,4(3)		; SAVE THE CURRENT PDL
	MOVMS	1		; POSITIVE
	SKIPGE	-1(P)		; HAVE WE GOT A SIGN ?
	JRST	ADECF0		; YES -- LESS THIS CHAR
	CAML	1,DTAB(2)	; AN OVERFLOW CONDITION ?
	PUSH	P,["*"]		; SET THE OVERFLOW FLAG
	CAML	1,DTAB-1(2)	; IN THIS RANGE ?
	JRST	ADECF1		; NO - EXIT
	PUSH	P,5		; PUSH THE FIELD CHAR
ADECF0:	SOJGE	2,.-3		; REPEAT FOR ALL
ADECF1:	JUMPN	1,ADECF		; NUMBER PRESENT ?
	POP	P,1
	JRST	ADECF		; YES -- POP OFF EXTRA SPACE
	POP	P,1		; POP ALL THE SPACES
	CALL	ACHAR%		; INTO THE LINE
ADECF:	CAME	P,4(3)		; ALL DONE ?
	JRST	.-3 		; NO,.-3
ADECF2:	MOVM	1,-1(P)		; GET BACK DATA
	SETZ	5,
	SKIPGE	-1(P)
	MOVEI	5,"-"
	JRST	ADECV

	RADIX	10
	+	0		; FOR THE ZERO ENTRY'S
DTAB:	+	1
	+	10
	+	100
	+	1000
	+	10000
	+	100000
	+	1000000
	+	10000000
	+	100000000
	+	1000000000
	RADIX	8
;
;	AOCTV% - THE OCTAL EDITING PROCEDURES
;

AOCTV%:: CALL	SAVE		; SAVE 1-5
AOCTV:	CALL	AOCT		; COMPUTE SIZE
	PUSH	P,5		; SAVE WC
	SETZ	1,		; PUT CHAR HERE
	LSHC	1,3		; GET THE DIGIT
	ADDI	1,"0"		; CVT TO ASCII
	CALL	ACHAR%		; INSERT IN BUFFER
	SOJG	5,.-4		; EDIT THEM ALL
	POP	P,5
	RET			; $E
;
;	AOCTF% - EDIT IN OCTAL A FIXED LENGTH - RIGHT JUSTIFIED
;

AOCTF%:: CALL	SAVE		; SAVE 1-5
	CALL	AOCT		; COMPUTE THE SIZE
	CALL	AOCTX		; EDIT THE FIELD
	JRST	AOCTV+1		; AND EDIT NUMBER
AOCT:	JFFO	1,.+2		; DETERMINE FIELD LENGTH
	SKIPA	2,[+^D11]	; A ZERO - DO 11
	IDIVI	2,3		; 2 = # BLANKS THIS WORD
	MOVN	5,2		; 5 = - BLANKS
	IMULI	2,3		; NOW NORMALIZE
	LSH	1,0(2)		; THE INPUT
	MOVE	2,1		; PUT NORMALIZED HERE
	ADDI	5,^D12		; 5 = # OF DIGITS
	RET

;
;	AOCTL% - EDIT OCTAL LEFT JUSTIFIED IN THE FIELD SPECIFIED
;


AOCTL%:: CALL	SAVE		; SAVE 1-5
	CALL	AOCTV		; EDIT IT IN
	CALL	AOCTX		; FILL THE FIELD
	RET			; AND RETRUN

AOCTX:	HRRZ	4,-3(P)		; GET DESIRED FIELD LENGTH
	SUBI	4,0(5)		; 4 = # OF CHARS LEFT OVER
	HLRZ	1,-3(P)		; GET THE FIELD CHARACTER
	SKIPN	1		; ZERO ?    YES,GET A BLANK
	MOVEI	1," "		; THIS BLANK
	SKIPGE	4		; FIELD LENGTH EXCEEDED ?
	SKIPA	1,["*"]		; YES - USE THIS CHARACTER
	CAIA			; AND CHECK FOR THE ZERO 
	CALL	ACHAR%		; EDIT THE CHARACTER
	SOJGE	4,.-1		; REPEAT FOR ALL
	RET			; EXIT
;
;	AEXIT% - EXIT FROM THE EDIT PACKAGE
;

AEXIT%:: CALL	SAVE		; SAVE OUR WORLD
	MOVEI	1,15
	CALL	ACHAR%
	MOVEI	1,12		; A CR/LF SEQUENCE AT THE END
	CALL	ACHAR%
	SETZM	1(3)		; WE ARE NO LONGER ALLOWED
	RET

;
;	ACHAR% - INSERT A SINGLE CHARACTER
;

ACHAR%:: EXCH	3,EDIT		; GET THE USER PACKET ADDRESS
	IDPB	1,1(3)		; SAVE THE CHARACTER
	SOSGE	2(3)		; IN BOUNDS ?
	CALL	AOOPS
	CAIE	1,12		; LF ??
	JRST	ACHAR		; NO,ACHAR
	EXCH	1,1(3)		; GET THE CURRENT BYTE POINTER
	MOVEM	1,3(3)		; SET FOR APOS%
	EXCH	1,1(3)		; RESTORE BYTE POINTER, CHAR
ACHAR:	EXCH	3,EDIT		; AN PUT IT BACK
	RET			; - RETURN

SAVE:	EXCH	5,0(P)		; SAVE 5 GET $E
	PUSH	P,4
	PUSH	P,3
	PUSH	P,2
	PUSH	P,1		; SAVE 1
	MOVE	3,EDIT		; PACKET IN USER AREA
	PUSHJ	P,0(5)		; RETURN AND CALL COROUTINE
	POP	P,1		; RESTORE THE REGISTERS
	POP	P,2
	POP	P,3
	POP	P,4
	POP	P,5
	RET

AOOPS:	OUTSTR	[ASCIZ/?EDIT PACKAGE STORING OUT OF BOUNDS/]
	OUTSTR	[BYTE (7)15,12]
	EXIT	1,
	RET

	LIT
	RELOC	0
EDIT:	Z
	END