80-Bus News

May–June 1983, Volume 2, Issue 3

The workings of NAS­COM ROM BASIC Ver 4.7

PAGE 6

FPREG

10E4

Floating point register.
This is a floating point number for the current value. It is a four byte store using 24 bit normalised sign and magnitude representation for the mantissa and excess 128 representation for the exponent of two.
Example of the number 35.25 in floating point:–

35.25 in binary is100011.01
Which is the same as100011.01 *2^ 00000000
The binary point is moved so that it precedes the first “1”
This gives.10001101
The point was moved left 6 times dividing the number by 2^6 so 6 must be added to the exponent to re-multiply by 2^6.
This gives.10001101 *2^ 00000110
As the bit after the point is ALWAYS “1” this bit can be used to store the sign of the number “0” for +ve, “1” for -ve
So +35.25 is stored as.00001101 * 2 ^ 00000110
Which in 24 bits is.000011010000000000000000 *2^ 00000110
128 is added to the exponent so that overflows and underflows can be more easily detected.
So the whole number in binary is:–
Which is
 00​00 11​01 00​00 00​00 00​00 00​00 10​00 01​10 0 D 0 0 0 0 8 6 HEX
The bytes of the mantissa are stored in reverse order.
This gives the value for +35.25 as00 00 0D 86
And −35.25 would be stored as00 00 8D 86

SGNRES

1088

Sign of result.
This contains the sign of the result for multiplication. Both values to be multiplied are tested and if their signs are different then the product will be negative otherwise it will be positive. The sign for the product is stored here so that it can be tested after to make the result correct.

PBUFF

10E9

Number print buffer.
When a floating point number has to be converted into ASCII for PRINT or STRS the ASCII number is built up in this buffer by NUMASC so that it can be output or assigned to a string.

NULVAL

10F6

Multiply value.
This contains the 24 bit multiplier because there are not enough registers to hold the multiplier, multiplicand and product all at the same time.

PROGST

10F9

Program start.
This is the byte before the first line in the program. It must be zero to tell the execution driver that the next (actually the first) line is to be executed.

The workings of NAS­COM ROM BASIC Ver 4.7

PAGE 7

******** How a program is stored in memory ********

Example:– The program:–

```  10 FOR A=1 TO 5:PRINT A,SQR(1):NEXT A
20 END
```

is in memory, it would look like this:–

 PROGND 111C Pointer to byte after program 10FA 15 11 Pointer to next line (1115) 10FC 0A 00 Line number (10) 10FE 81 FOR token 10FF 20 Space 1100 41 A 1101 B4 = token 1102 31 1 1103 20 Space 1104 A6 TO token 1105 20 Space 1106 35 5 1107 3A : 1108 9E PRINT token 1109 20 Space 110A 41 A 110B 2C , 110C BA SQR token 110D 28 ( 110E 41 A 110F 29 ) 1110 3A : 1111 82 NEXT token 1112 20 Space 1113 41 A 1114 00 End of line 1115 1A 11 Pointer to next line (111A) 1117 14 00 Line number (20) 1118 80 END token 1119 00 End of line 111A 00 00 Pointer to next line (0000 = End of program) 111C

NASCOM ROM BASIC source code is available in ASM and LST file format.