Commodore 2001-8 User Manual page 95

Table of Contents

Advertisement

with a POKE of the decimal equivalent of the lower address to location 2 and POKE of the high order ad-
dress in location 2. Example:
10POKE 1,122
20POKE 2,2
30 IF USR (AI
=
1 THEN
etc.
USEFUL BASIC SUBROUTINES
There are a series of sUbroutines in BASIC which can allow the machine language program to evaluate
values in the floating accumulator. These functions are called jump to Subroutines instruction (JSR)to
the address.
The parameter specified in the USR functon is evaluated, converted to a binary floating point equivalent
with signs, exponent, and mantissa, and placed in a series of 6 bytes which we will call the floating
accumulator
$80
sign and exponent
$81
mantissa MSB
$82
mantissa
$83
mantissa
$84
mantissa
$B5
mantissa LSB
$B6
sign of mantissa
The exponent is computed such that the mantissa 0= 1 x 1. It is stored as a signed 8 bit binary +$80.
Negative exponents are not stored 2's complement. Maximum exponent is 10
38
Minimum exponent is
10
39
which is stored as $00. A zero exponent is used to flag the number as zero.
Exponent
Approximate Value
FF
10~
A2
10
10
7F
10 -
1
02
10
38
00
10-
39
Since the exponent is really a power of 2, it should best be described as the number of left shifts
(EXP>$80) or right shifts (EXP<
=
$80) to be performed on the normalized mantissa to create the actual
binary representation of the value.
Since the mantissa is always normalized, the high order bit of the most significant byte is always set.
This guarantees always at least 40 bits precision which is roughly equivalent to 9 significant digits pius a
few bits for rounding. If a number has a value of zero, itmay not always have zero bytes in the mantissa.
The only true flag for a zero number is the exponent. See Figure 8.1 for example exponents and
mantissa's.
If the mantissa is positive, then the sign byte is zero -- $00. A negative mantissa Causes this byte to be
·l··$FF.
93

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pet 2001-8

Table of Contents