Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-03 - decus/20-0078/libsim/octal.mac
There is 1 other file named octal.mac in the archive. Click here to see a list.
COMMENT * SIMULA specification;
OPTIONS(/E:QUICK,octal);
TEXT PROCEDURE octal(t,i); INTEGER i; TEXT t;
COMMENT Convert i to octal digits in t.
If t is too short to contain all non-zero digits, it will contain the last
digits only. Pos will point to the first non-zero digit.
Octal is a reference to the string of digits, at most 12.
;

!*;! MACRO-10 code !*;!

	TITLE	octal
	ENTRY	octal
	SUBTTL	SIMULA utility, Lars Enderin Oct 1977

;!*** Copyright 1977 by the Swedish Defence Research Institute. ***
;!*** Copying is allowed.					***


	sall
	search	simmac,simmcr,simrpa
	macinit

	;! Local definitions ;!

	t==<result==XWAC1>
	i==t+2
	b==i+2
	n==XIAC


octal:	PROC
	EXCH	t,(XTAC)
	EXCH	t+1,1(XTAC)
	EXCH	i,2(XTAC)
	STACK	b
	L	i
	IF	;! Not zero
		JFFO	TRUE
		GOTO	FALSE
	THEN
		L	X1
		IDIVI	3
	FI
	STACK	;! Number of zero bytes
	LF	b,ZTVZTE(,t)
	LF	,ZTVSP(,t)
	IF	JUMPN FALSE
	THEN	ADD b,[POINT 7,2]
	ELSE
		IDIVI 5
		ADD b,
		ADD b,[POINT 7,2
			  POINT 7,2,6
			  POINT 7,2,13
			  POINT 7,2,20
			  POINT 7,2,27](X1)
	FI
	LF	X1,ZTVLNG(,t)	;! result.Length:=min(12,t.Length)
	CAIL	X1,^d12
	 LI	X1,^d12
	SF	X1,ZTVLNG(,t)
	L	(XPDP)	;! Number of initial zeros
	LI	n,^d12
	SUBI	n,(X1)
	SUBI	(n)
	SKIPG
	 SETZ
	SF	,ZTVCP(,t)
	IF JUMPE n,FALSE
	THEN IMULI n,3
	  ROT	i,(n)
	FI
	L	X1,i
	LF	n,ZTVLNG(,t)
	WHILE
		SOJL	n,FALSE
	DO
		SETZ
		LSHC	3
		ADDI	"0"
		IDPB	b
	OD
	UNSTK	(XPDP)
	UNSTK	b
	EXCH	i,2(XTAC)
	EXCH	t+1,1(XTAC)
	EXCH	t,(XTAC)
	RET
	EPROC
	LIT
	END;