Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-10 - 43,50517/move.mac
There are 10 other files named move.mac in the archive. Click here to see a list.
	TITLE	MOVE FOR LIBOL V10 AND RPGLIB V1
	SUBTTL	MOVE A STRING OF CHARACTERS	15-DEC-74	/ACK

;LIBOL VERSION
;COPYRIGHT 1975, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
;RPGII VERSION COPYRIGHT BOB CURRIER, 1976

;REVISION HISTORY:

;V10 *****

;	15-DEC-74	/ACK	CREATION.
;	26-JAN-75	/ACK	REWRITTEN - BAD REGISTER ALLOCATION.
;				 (T1 AND CH WERE THE SAME REGISTER, WHICH
;				 SCREWED UP BLT'S.)

;	5/10/75		/DBT	BIS CODE
;*****

	SEARCH	RPGPRM		;DEFINE PARAMETERS.
	%%LBLP==:%%LBLP
	DEBUG==:DEBUG
	BIS==:BIS

	EXTERN	EASTB.		;FORCE EASTBL TO BE LOADED.

	HISEG

COMMENT	\

	THIS ROUTINE MOVES A STRING OF CHARACTERS FROM ONE PLACE TO ANOTHER.

CALL:
	MOVEI	16,PARAMETER ADDRESS
	PUSHJ	17,MOVE.

PARAMETERS:
	WORD 1:
		BYTE POINTER TO THE INPUT STRING.
	WORD 2:
		BITS	0-5	BYTE POINTER RESIDUE FOR THE OUTPUT STRING.
		BIT	6	IGNORED (1 IF THE FIELD IS EXPLICTLY SIGNED.)
		BITS	7-17	SIZE OF THE FIELDS.
		BITS	18-35	ADDRESS OF THE FIRST BYTE OF THE OUTPUT FIELD.

RETURNS:
	CALL+1	ALWAYS.

REGISTERS USED:
	JAC, CNT, CH, TAC2, TAC3, TAC4, IPTR, OPTR

\
	ENTRY	MOVE.

	EXTERN	SET2.		;ROUTINE TO PICK UP THE PARAMETERS.
	EXTERN	RET.1		;RETURNS TO CALL+1.

	EXTERN	PTIBS.		;POINTER TO THE INPUT BYTE SIZE.
	EXTERN	PTOBS.		;POINTER OT THE OUTPUT BYTE SIZE.

	T1==TAC2
	T2==TAC2+1	;ALSO KNOWN AS TAC3.
	T3==TAC4

	CNT==4			; [172] ********** NOTE WELL **********

IFN	BIS,<

;MAKE SURE THAT THE REGISTERS DON'T GET SCREWED UP.

	CHKREG==0
	IFN CNT-SRCCNT,<CHKREG==1>
	IFE SRCPT-CNT,<CHKREG==1>
	IFE SRCPT-OPTR,<CHKREG==1>
	IFE DSTCNT-OPTR,<CHKREG==1>
	IFN CHKREG,<
	PRINTX	?MOVE IS BROKEN - BAD REGISTER ALLOCATION - CHECK LISTING.
	CNT==4			; [172] ********** NOTE WELL **********
	SRCCNT==SRCCNT
	SRCPT==SRCPT
	DSTCNT==DSTCNT
	OPTR==OPTR
>
>

MOVE.:	JSP	JAC,	SET2.		;GO PICK UP THE PARAMETERS.
	EXP		RET.1		;RETURN THROUGH HERE ON A NULL STRING.
	MOVE	CNT,	12		; [172] GET CNT BACK FROM SET2.
	LDB	T3,	PTIBS.		;GET THE INPUT BYTE SIZE.
	DPB	T3,	PTOBS.		;MAKE IT THE OUTPUT BYTE SIZE.
	CAIG	CNT,	^D15		;WORTH TRYING TO BLT?
	JRST		MOVE4		;NO, GO MOVE CHAR'S.

	HLRZ	T1,	IPTR
	HLRZ	T2,	OPTR
	CAIE	T1,	(T2)		;IS A BLT POSSIBLE?
	JRST		MOVE4		;NO, GO MOVE CHAR'S.

;THE FOLLOWING LOOP SHOULD BE EXECUTED AT MOST FIVE TIMES.

	TRZ	T1,	770077		;BYTE SIZE IN BITS 24-29.
MOVE1:	LDB	T2,	[POINT 12,IPTR,11]	;NUMBER OF BITS LEFT.
	CAIG	T2,	(T1)		;LESS THAN ONE BYTE LEFT?
	JRST		MOVE2		;YES, GO MOVE UP TO NEXT WORD AND BLT.
	CAIL	T2,	4400		;ARE WE AT A WORD BOUNDARY?
	JRST		MOVE3		;YES, GO BLT.
	ILDB	CH,	IPTR		;MOVE UP ONE BYTE.
	IDPB	CH,	OPTR
	SOJG	CNT,	MOVE1		;LOOP.
IFE DEBUG,<
	POPJ	PP,			;THIS CAN'T HAPPEN! (BUT JUST IN
					; CASE - NO HARM DONE.)
>
IFN DEBUG,<
	OUTSTR	[ASCIZ	/
%MOVE FELL THROUGH WHILE LOOKING FOR A WORD BOUNDARY.
%AT MOVE1+6 IN MOVE.
/]
	HALT		RET.1
>
;MOVE UP TO THE NEXT WORD BECAUSE THERE IS LESS THAN 1 BYTE LEFT IN
; THIS ONE, THIS SHOULD ONLY HAPPEN FOR ASCII.

MOVE2:	AOS		IPTR
	AOS		OPTR
	MOVEI	CH,	44
	DPB	CH,	[POINT 6,IPTR,5]
	DPB	CH,	[POINT 6,OPTR,5]

;WE CAN BLT AT LEAST ONE WORD.

MOVE3:	IDIV	CNT,	CHPRWD-6(T3)	;NUMBER OF WORDS TO TRANSFER (NOTE:
					; NUMBER OF CHARACTERS LEFT IS IN
					; CH).
	HRRI	T2,	(OPTR)		;DESTINATION.
	HRLI	T2,	(IPTR)		;SOURCE.
	ADDI	OPTR,	(CNT)		;LAST WORD IN DESTINATION + 1.
	BLT	T2,	-1(OPTR)	;FINALLY!!
	JUMPE	CH,	RET.1		;ANY MORE BYTES?
	ADDI	IPTR,	(CNT)		;YES, UPDATE THE SOURCE POINTER.
	MOVEI	CNT,	(CH)		;AND THE COUNT.

;COME HERE WHEN ALL ELSE FAILS.

MOVE4:
IFE	BIS,<
	ILDB	CH,	IPTR		;GET A CHAR.
	IDPB	CH,	OPTR		;STASH IT.
	SOJG	CNT,	MOVE4		;LOOP IF THERE ARE MORE.
	POPJ	PP,			;OTHERWISE RETURN.
>		;END NON-BIS BYTE MOVE

IFN	BIS,<
	MOVE	SRCPT,IPTR		;SET UP THE AC'S FOR THE
	MOVE	DSTCNT,CNT		; MOVSLJ.
	MOVE	DSTPT,OPTR
	EXTEND	CNT,[MOVSLJ,,0]		;DO THE MOVE.
	JRST	ERROR
	POPJ	PP,			;DONE

ERROR:	OUTSTR	[ASCIZ	'?LIBOL MOVE ERROR
']
	POPJ	PP,

>	;END BIS


;TABLE OF CHARACTERS PER WORD:

CHPRWD:	EXP	6
	EXP	5
	EXP	0
	EXP	4

	END