Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-05 - 43,50337/17/ma.mac
There are 2 other files named ma.mac in the archive. Click here to see a list.
	SUBTTL	Mathematical subroutines not covered by FORLIB

; Author:	Peter W. Steele, Acadia Univ. June 1978

	SEARCH	SIMMAC,SIMRPA
	SALL
	RTITLE	MA
	ERRMAC	MA
	MACINIT

	ENTRY	.MACI, .MACL
Comment;

Purpose:	To convert an arithmetic value from long real to integer
		(.MACI) or vice versa (.MACL).
		These routines have been rewritten for SIMULA on the KA10
		so as to avoid calling KA10 dependent UUO's and also to
		correct the bug in the .MACI routine which caused improper
		rounding of negative numbers. (i. e., all numbers of the
		form -X.5 rounded to -X+1 instead of -X.)

Input:		Value to be converted in Xtop (and Xtop+1).
		XTAC=Xtop.

Output:		Converted value in Xtop (& Xtop+1).

Function:	Load input by EXCH instructions to XWAC1-XWAC2.
		Convert in XWAC1-XWAC2 and place result by EXCH.

;
.MACL:	PROC	;Conversion from integer to long real
	EXCH	XWAC1,(XTAC)
	EXCH	XWAC2,1(XTAC)
	IDIVI	XWAC1,400
	SKIPE	XWAC1
	TLC	XWAC1,243000
	TLC	XWAC2,233000
	FADL	XWAC1,XWAC2
	EXCH	XWAC2,1(XTAC)
	EXCH	XWAC1,(XTAC)
	RETURN
	EPROC

.MACI:	PROC	;Conversion from long real to integer
	EXCH	XWAC1,(XTAC)
	EXCH	XWAC2,1(XTAC)
	STACK	XWAC3
	L	XWAC3,XWAC2
	FADL	XWAC1,[0.5]
	UFA	XWAC2,XWAC3
	FADL	XWAC1,XWAC3
	HLRZ	XWAC3,XWAC1
	LSH	XWAC3,-11
	ANDI	XWAC3,377
	TLZ	XWAC1,377000
	IF	;XWAC1 < 0
		JUMPGE	XWAC1,FALSE
	THEN
		TRC	XWAC3,377
		TLO	XWAC1,377000
	FI
	LSH	XWAC2,10
	ASHC	XWAC1,-233(XWAC3)
	UNSTK	XWAC3
	EXCH	XWAC1,(XTAC)
	EXCH	XWAC2,1(XTAC)
	RETURN
	EPROC
	LIT
	END