<<<--- % 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 s IS $6 $w$ unpacked e IS $7 carry IS $8 The shuttle between $x_1$ and $x_0$. su IS $9 $u$ unpacked eu IS $10 sv IS $11 $v$ unpacked ev IS $12 d IS $13 $e_u - e_v$ tmp IS $14 --->>> DFmul SLU eu,u1,1; SLU ev,v1,1 \ul{\sl M1.~Unpack.} SRU eu,eu,49; SRU ev,ev,49 XOR s,u1,v1; SRU s,s,63 $s_w \is s_u\cdot s_v$ SLU u1,u1,8 $(u_1,u_0) \is u2^8$ ANDNH u1,#FF00; ORH u1,#0100 SRU carry,u0,64-8; ADDU u1,u1,carry SLU u0,u0,8 SLU v1,v1,8 $(u_1,u_0) \is u2^8$ ANDNH v1,#FF00; ORH v1,#0100 SRU carry,v0,64-8; ADDU v1,v1,carry SLU v0,v0,8 % \ul{\sl M2.~Operate.} MULU tmp,u1,v0; GET w0,rH $w_0 \is 2^{48+8}u_12^8v_0=2^64u_1v_0$ MULU tmp,u0,v1 GET tmp,rH; ADDU w0,w0,tmp $w_0 \is w_0 + 2^{48+8}u_12^8v_0=2^64u_1v_0$ MULU tmp,u1,v1; GET w1,rH $(w_1,\cdot) \is 2^{48+8}u_12^{48+8}v_1=2^{48+64}u_1v_1$ ADDU w0,w0,tmp CMPU tmp,w0,tmp; ZSN carry,tmp,1 $\.{carry} \is 1$ if $w_0+\.{tmp}<\.{tmp}$ ADDU w1,w1,carry ADD e,eu,ev SET tmp,#3FFF; SUB e,e,tmp $e\is e_u+e_v-q$ JMP DNormalize \ul{\sl M3.~Normalize.} <<<--- 32 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,DFmul SET $255,0 TRAP 0,Halt,0 Error SET $255,1 TRAP 0,Halt,0 --->>>