<<<--- % Author M.Ruckert LOC #100 u1 IS $0 1. parameter u0 IS $1 1. parameter v1 IS $2 2. parameter v0 IS $3 2. parameter w1 IS $4 return value w0 IS $5 return value w00 IS $6 s IS $7 $w$ unpacked e IS $8 carry IS $9 The shuttle between $x_1$ and $x_0$. su IS $10 $u$ unpacked eu IS $11 sv IS $12 $v$ unpacked ev IS $13 d IS $14 $e_u - e_v$ tmp IS $15 --->>> DFmul XOR s,u1,v1; SRU s,s,63 $s_w \is s_u\cdot s_v$ SLU eu,u1,1; SLU ev,v1,1 \ul{\sl M1.~Unpack.} SRU eu,eu,49; SRU ev,ev,49 ANDNH u1,#FFFF; ORH u1,#0001 ANDNH v1,#FFFF; ORH v1,#0001 % \ul{\sl M2.~Operate.} MULU tmp,u1,v0; GET w0,rH $(w_0,\cdot) \is 2^{48+64}u_12^{64}v_0$ MULU tmp,u0,v1; GET tmp,rH; ADDU w0,w0,tmp $w_0 \is w_0 + 2^{48}u_0v_1$ MULU tmp,u1,v1; GET w1,rH $(w_1,\cdot) \is 2^{48}u_12^{48}v_1=2^{32+64}u_1v_1$ ADDU w0,w0,tmp $w_0 \is w_0 +\cdot$ CMPU tmp,w0,tmp; ZSN carry,tmp,1 $\.{carry} \is 1$ if $w_0+\cdot<\cdot$ ADDU w1,w1,carry ADD e,eu,ev SLU w1,w1,16 SRU carry,w0,64-16; ADDU w1,w1,carry SLU w0,w0,16 SET tmp,#3FFF; SUB e,e,tmp $e\is e_u+e_v-q$ JMP DNormalize \ul{\sl M3.~Normalize.} <<<--- 28 instructions DNormalize SRU tmp,w1,49; BP tmp,4F \ul{\sl N1.~Test $f$.} If $w\ge 2$, scale right. OR tmp,w1,w0; BZ tmp,Error underflow 2H SRU tmp,w1,48; BP tmp,5F \ul{\sl N2.~Is $w$ normalized?} ZSN carry,w0,1; SLU w0,w0,1 \ul{\sl N3.~Scale left.} SLU w1,w1,1; ADDU w1,w1,carry SUB e,e,1 JMP 2B 4H AND carry,w1,1 \ul{\sl N4.~Scale right.} SLU carry,carry,63 SRU w0,w0,1; ADDU w0,w0,carry SRU w1,w1,1 ADD e,e,1 % \ul{\sl N5.~Round.} omitted 5H SET tmp,#7FFE; CMP tmp,e,tmp \ul{\sl N6.~Check $e$.} BP tmp,Error Overflow BNP e,Error Underflow SLU s,s,63 \ul{\sl N7.~Pack.} SLU e,e,48; ANDNH w1,#FFFF remove hidden bit OR w1,w1,s; OR w1,w1,e SET $0,w0 SET $1,w1 POP 2,0 Main SETML $2,0 1.0 INCH $2,#3FFF+10 exponent 10 ORH $2,#8000 negativ SET $3,0 $2,$3 <- -1024.0 SETML $4,#0040 1.0000 0000 0100 0000 INCH $4,#3FFF+10 exponent 10 ORH $4,#0000 positive SET $5,0 $4,$5 <- +1025.0 PUSHJ $1,DFdiv SET $255,0 TRAP 0,Halt,0 Error SET $255,1 TRAP 0,Halt,0 --->>>