ieeewrf2.abm (F2-CP128)
900 R=0 : GOSUB 1070 : DELAY 5000
910 R=-1 : GOSUB 1070 : DELAY 5000
1000 R=80 : GOSUB 1070 : DELAY 5000
1010 R=6.8 : GOSUB 1070 : DELAY 5000
1020 R=.4 : GOSUB 1070 : DELAY 5000
1030 R=12.34568 : GOSUB 1070 : DELAY 5000
1040 R=.047067 : GOSUB 1070 : DELAY 5000
1050 R=-6.587E+24 : GOSUB 1070 : DELAY 5000
1052 R=.25 : GOSUB 1070 : DELAY 5000
1054 R=.5 : GOSUB 1070 : DELAY 5000
1056 R=-.25 : GOSUB 1070 : DELAY 5000
1058 R=-.5 : GOSUB 1070 : DELAY 5000
1060 END
1070 REM FLOATING POINT TO IEEE PATTERN CONVERSION
1080 REM
1090 REM FIRST CONVERT FLOATING POINT TO BASE 2
1100 PRINT1 “Floating Point = “,R
1110 E=0 : REM INITIALIZE THE EXPONENT
1120 N=ABS(R)
1125 IF N=0 THEN B0=0 : B1=0 : B2=0 : B3=0 : GOTO 1400
1130 IF N<1.0 THEN GOTO 1190
1140 DO : REM NUMBER IS GREATER THAN 0
1150 N=N/2 : REM FRACTIONAL PART OF FLOATING POINT NUMBER
1160 E=E+1 : REM 2**E
1170 UNTIL INT(N)=0
1180 GOTO 1260
1190 D=1
1200 DO : REM NUMBER IS LESS THAN 0
1210 E=E-1
1220 D=D/2
1230 UNTIL D<=N
1240 D=D*2 : E=E+1
1250 N=N/D
1260 E=E+126 : REM IEEE EXPONENT
1270 REM Convert BCD to 6 digit (24-bit) HEX value
1280 REM PRINT1 “Exponent = “,E, SPC (2),HEX$(E,1)
1290 BF1=N*256 : B1=INT(BF1)
1300 REM PRINT1 “Byte 1 = “,B1, SPC (2),HEX$(B1,1)
1310 BF2=(BF1-B1)*256 : B2=INT(BF2)
1320 REM PRINT1 “Byte 2 = “,B2, SPC (2),HEX$(B2,1)
1330 B3=INT((BF2-B2)*256+.5)
1340 REM PRINT1 “Byte 3 = “,B3, SPC (2),HEX$(B3,1)
1350 REM
1360 REM PACK THE IEEE EXPONENT DOUBLE WORD
1370 REM
1380 B0=E/2 : IF R<0 THEN B0=B0.OR.80H
1390 IF E/2-INT(E/2)<>0 THEN B1=B1.OR.80H ELSE B1=B1.AND.7FH
1400 PRINT1 “IEEE = “,
1410 PRINT1 RIGHT$(HEX$(B0),2), : SHARED(130,H)=B0
1420 PRINT1 RIGHT$(HEX$(B1),2), : SHARED(130,L)=B1
1430 PRINT1 RIGHT$(HEX$(B2),2), : SHARED(128,H)=B2
1440 PRINT1 RIGHT$(HEX$(B3),2) : SHARED(128,L)=B3
1450 PRINT1 : BMOVE W,VH(2002),K(4)
1460 RETURN