; IOProcs.Asm - 12/15/86 ; I/O and floating point library routines for compiled programs .TRAP _FP68K $A9EB ; Trap to call Macintosh floating point package _input DS.B 16 ; Storage for terminal input and output files _output DS.B 16 XREF PAS$InitMacEnv XREF PAS$CreatePWnd XREF PAS$Weoln XREF PAS$WInteger XREF PAS$WReal XREF PAS$Reoln _Init: JSR PAS$InitMacEnv ; Initialize the Macintosh environment PEA _input(A5) ; Initialize the terminal input and output PEA _output(A5) JSR PAS$CreatePWnd RTS _Exit: PEA _input(A5) JSR PAS$Reoln RTS WriteInt: PEA _output(A5) ; Write the integer MOVE.W 8(A7),-(SP) CLR.W -(SP) JSR PAS$WInteger PEA _output(A5) ; Skip to the next line JSR PAS$Weoln MOVE.L (A7)+,A0 ADDQ.W #2,A7 JMP (A0) WriteReal: LINK A6,#-10 PEA 8(A6) ; Convert the single precision real PEA -10(A6) ; to an extended precision real MOVE.W #$100E,-(A7) ; FS2X _FP68K PEA _output(A5) ; Write the extended precision real PEA -10(A6) CLR.W -(SP) CLR.W -(SP) JSR PAS$WReal PEA _output(A5) ; Skip to the next line JSR PAS$Weoln UNLK A6 MOVE.L (A7)+,(A7) RTS _Int2Real: LINK A6,#-10 ; Space for extended precision temp MOVE.W D0,-(A7) ; Push the integer for conversion PEA (A7) ; Push addresses of parameters for FI2X PEA 6(A7) MOVE.W #$200E,-(A7) ; FI2X _FP68K SUBQ.W #2,A7 ; Add 2 bytes from integer to make real PEA 4(A7) ; Push addresses of parameters for FX2S PEA 4(A7) MOVE.W #$1010,-(A7) ; FX2S _FP68K MOVE.L (A7)+,D0 ; Get the single precision real UNLK A6 RTS _Real2Int: LINK A6,#-10 ; Space for extended precision temp MOVE.L D0,-(A7) ; Push the real for conversion PEA (A7) ; Push addresses of parameters for FS2X PEA 8(A7) MOVE.W #$100E,-(A7) ; FS2X _FP68K ADDQ.W #2,A7 ; Get rid of 2 bytes from real to make integer PEA 2(A7) ; Push addresses of parameters for FX2I PEA 4(A7) MOVE.W #$2010,-(A7) ; FX2I _FP68K MOVE.W (A7)+,D0 ; Get the integer UNLK A6 RTS ; How to call _FCmp: ; Eval left side ; MOVE.L D0,-(A7) ; Eval right side ; JSR _FCmp ; Scc D0 (where 'cc' is the appropriate condition to test for) ; EXT.W D0 _FCmp: MOVEA.L (A7)+,A0 ; Get return address MOVE.L (A7)+,D1 ; Left side of expr to D1 MOVE.L A0,-(A7) ; Put return address back LINK A6,#-10 ; Space for extended precision temp MOVE.L D0,-(A7) ; Push the right side for conversion PEA (A7) ; Push addresses of parameters for FS2X PEA 8(A7) MOVE.W #$100E,-(A7) ; FS2X _FP68K MOVE.L D1,-(A7) ; Push the left side PEA (A7) ; Push addresses of parameters for FCMPS PEA 8(A7) MOVE.W #$100D,-(A7) ; FCMPS _FP68K UNLK A6 RTS _RNeg: LINK A6,#-10 ; Space for extended precision temp MOVE.L D0,-(A7) ; Push the real for conversion PEA (A7) ; Push addresses of parameters for FS2X PEA 8(A7) MOVE.W #$100E,-(A7) ; FS2X _FP68K PEA (A7) ; Push address of parameter for FNEGX MOVE.W #$000D,-(A7) ; FNEGX _FP68K SUBQ.W #4,A7 ; Reserve space for single precision result PEA 4(A7) ; Push addresses of parameters for FX2S PEA 4(A7) MOVE.W #$1010,-(A7) ; FX2S _FP68K MOVE.L (A7)+,D0 ; Get the single precision real UNLK A6 RTS ; How to call _Flop: ; Eval left side ; MOVE.L D0,-(A7) ; Eval right side ; MOVE.W #flop,D2 ; JSR _Flop _Flop: MOVEA.L (A7)+,A0 ; Get return address MOVE.L (A7)+,D1 ; Left side of expr to D1 MOVE.L A0,-(A7) ; Put return address back LINK A6,#-10 ; Space for extended precision temp MOVE.L D1,-(A7) ; Push the left side for conversion PEA (A7) ; Push addresses of parameters for FS2X PEA 8(A7) MOVE.W #$100E,-(A7) ; FS2X _FP68K MOVE.L D0,(A7) ; Push the right side PEA (A7) ; Push addresses of parameters for the flop PEA 8(A7) MOVE.W D2,-(A7) ; Push the flop's selector word _FP68K PEA 4(A7) ; Push addresses of parameters for FX2S PEA 4(A7) MOVE.W #$1010,-(A7) ; FX2S _FP68K MOVE.L (A7)+,D0 ; Get the single precision real UNLK A6 RTS