PATCH FILE FOR CC103 IN DECUS 11-SP-18 KIT

Purpose:- The compiler D switch, which is the default, does not work properly.
It fails to convert floating arguments in function calls to type double, the
code in the function assumes that they are double so for arguments other
than the first it pulls in garbage. It also fails to convert the result
of a floating function to double before passing it back, though the code in
the calling function assumes it is double. This mess seems to have arisen
as a result of a series of design changes to the language. The original plan
seems to have been to adopt the UNIX usage of converting floats to 
doubles for passing to and from functions. That was then changed (edit u1)
to make ordinary floats the standard. Later (edit 04) allowed these
options to be controlled by the D and F switch system, however it appears
the appropriate code to implement that was never put in for the two cases
listed. This patch file aims to rectify these faults.

Method:- All the edits are in file CC103.MAC, and are labelled as set out
in the first 2 lines of the change file. b1 is simple, it only involved
inserting a type change on seeing the FFLAG set clear, as has been done
elsewhere in the program. b2 is more complex. It finds the floating function
arguments at tree build time and pushes a float-to-double cast onto the
name stack, then calls BUILD with a #OP.COT operator. After that it pops
the name stack and reenters BUILD at the point where it digressed.

Patching:- Patch the CC103.MAC file using SLP. The commands are

R SLP
CC103.NEW=CC103.OLD,CC103.DIF/A/T

where CC103.OLD is the 11-SP-18 version of CC103.MAC, CC103.NEW is the
result of the patch and CC103.DIF is the differences file which begins
with the line -35,36 below.


-35,36
; b1 30-Aug-84 HFR	Convert returned floats to double for D switch.
; b2 02-Sep-84 HFR	Cast floating function args to doubles for D switch.

-101,101
-660
	CMP	R3,#OP.JSR	;FUNCTION CALL RIGHT OP IS FIRST ARG	;b2+
	BEQ	15$		;SO CHECK IT OUT
	CMP	R3,#OP.SEQ	;RIGHT OP IS LATER FUNCTION ARGS
	BEQ	15$		;SKIP IF NOT
	CMP	R3,#OP.CMA	;RIGHT OP IS A FN ARG IF
	BNE	17$		;(NO IT ISN'T)
	CMP	@OPTR,#OP.JSR	;TOP OF STACK IS FUNCTION CALL
	BNE	17$		;NO IT ISN'T
15$:	CALL	CHFLOT		;CHECK FOR FLOAT TO DOUBLE ARG CONV
17$:									;b2-
-668
	CMP	R3,#OP.SEQ	;LEFT OP IS FUNCTION ARG		;b2+
	BEQ	21$		;SO CHECK IT
	CMP	R3,#OP.CMA	;LEFT OP IS FN ARG IF
	BNE	22$		;(NO IT ISN'T)
	CMP	@OPTR,#OP.JSR	;TOP OF STACK IS FUNCTION CALL
	BNE	22$		;NO IT ISN'T
21$:	CALL	CHFLOT		;CHECK FOR FLOAT TO DOUBLE ARG CONV
22$:									;b2-
-815,815
176$:							;u1+/04+
-1681
CHFLOT:	TSTB	FFLAG		;FLOAT ARGS TO DOUBLES?			;b2+
	BNE	30$		;NO, RETURN
	TST	E.DIMP(R2)	;IS IT A SCALAR
	BNE	30$		;NO, RETURN
	CMPB	E.TYPE(R2),#TY.FLT	;FLOAT TYPE ARG?
	BNE	30$		;NO, RETURN
	MOV	R3,-(SP)	;WE HAVE ONE, SO SAVE OPERATOR
	MOV	R2,-(SP)	;SAVE OPERAND FOR LATER PUSHBACK
	MOV	E.DIMP(R2),-(SP);SAVE DIMS INFO FOR TRANSFER
	MOV	#ES.OP,R2	;BUILD A CAST NODE
	CALL 	TREES1		;GET SPACE
	MOV	#OP.COT,(R2)	;LOAD OPERATOR
	MOVB	#TY.DBL,E.TYPE(R2)	;SET TYPE
	MOV	(SP)+,E.DIMP(R2)	;AND DIMS
	CALL	BUMPN		;PUT NEW NODE ON
	MOV	R2,@NPTR	;NAME STACK
	CALL	BUMPN		;AND PUSH BACK
	MOV	(SP)+,@NPTR	;ORIGINAL NODE
	MOV	#OP.COT,R3	;CURRENT OPERATOR
	CALL	BUILD		;ADD IN TO TREE
	MOV	@NPTR,R2	;GET NEW CURRENT NODE
	SUB	#2,NPTR
	MOV	(SP)+,R3	;RESTORE OPERATOR

30$:	RETURN								;b2-

-1881
	TSTB	FFLAG		;FORCE FLOAT TO DOUBLE IF CLEAR		;b1+
	BNE	5$
	CMP	#TY.FLT,R1	;IS TYPE FLOAT
	BNE	5$		;NO, CONTINUE
	MOV	#TY.DBL,R1	;YES, CONVERT TYPE
5$:									;b1-
/
                                                                                                                                                                                                                                                                                                                                                                                                                                            