From: French Luser
newsgroup: comp.os.cpm
Date: Wed, 27 Sep 2006 13:37:14 +0200
Subject: Lawrence Livermore Laboratory Floating-Point Package doc
LLLFP.WS4
---------
Lawrence Livermore Laboratory Floating-Point (LLLFP) package
Original title:
- "Floating-Point Package for Intel 8008 and 8080 Microprocessors"
Michael D. Maples
Lawrence Livermore Laboratory,
University of California/Livermore, California 94550,
October 24, 1975
(Retyped by Emmanuel ROCHE.)
UCRL-51940
Work performed under the auspices of the U.S. Department of
Energy by Lawrence Livermore Laboratory under Contract
W-7405-ENG-48.
Distribution Category: UC-32
Contents
--------
Abstract
Introduction
Selection and use of operations
Acknowledgments
Appendix: Source listing of Floating-Point Package
Abstract
--------
The Lawrence Livermore Laboratory has used a scientific-notation
mathematics package that performs Floating-Point arithmetic with
Intel 8008 and 8080 microprocesors. The execution times for the
mathematical operations -- add, subtract, multiply, divide, and
square root -- range from 3 to 77 ms. Instructions for using the
Floating-Point Package and a source listing of it are included.
Introduction
------------
For the last two years, Lawrence Livermore Laboratory has used a
scientific-notation mathematics package (Floating-Point Package)
with the Intel 8008 and 8080 microprocessors. This package
allows addition, subtraction, multiplication, division, and
square root operations. Table 1 shows the execution times for
these operations. The program listing of the complete 8080
Floating-Point Package is in the Appendix. The package uses some
I/O calls from an octal debug routine (ODT) that has become a
standard part of all inhouse LLL microcomputers, but this need
not be necessary. The appropriate ODT calls (6 or 7) in the I/O
routines can easily be replaced by assembly language
equivalents.
Table 1. Worst-case execution times for the 8080 microprocessor
using a 0.5-us clock with the package in programmable read-only
memory (PROM)
Operation Execution times (ms)
--------- --------------------
Add 3
Subtract 3
Multiply 7
Divide 8
Square root 77
The Floating-Point Package uses 24 bits of mantissa for
approximately 7-1/2 digits of accuracy in expressing numeric
data. Obviously, this decreases rapidly when complex iterative
computations are used. Nevertheless, the package is functioning
quite satisfactorily in many experiments, with accuracy
requirements of one part per hundred thousand.
The package also indicates underflows and overflows, by placing
zeros in the mantissa and a 64 (decimal) in the exponent word.
Selection and use of operations
-------------------------------
All registers described in this paper points to four-word
internal mathematical storage areas, unless otherwise stated.
Also, before performing any mathematical operation, all needed
operands must be placed in the same random access memory (RAM),
along with any needed scratch areas (i.e., all must reside in
the same page of RAM). (ROCHE> Obviously, the author of this
paper has NOT the same idea of what is a "page" and a "word"
than me...)
The first problem is how to get the decimal numbers into the
correct format for use in the Floating-Point Package. The
routine INPUT performs the conversion for all teletypewriter
input. Also, it easily adapts to converting any BCD numeric
inputs from either digital panel meters (DPM) or thumbwheel
switches. To use INPUT, set the L-register to point at the
location in RAM where the result of the conversion is to be
placed, and set the C-register to point to another location in
RAM where intermediate steps are to be calculated. Then, do a
call to the INPUT routine that does the appropriate conversion
(see Table 2).
Table 2. Program for using INPUT routine. The scratch area is
15 (decimal) bytes long, but the converted number is only 4
bytes long.
Program Comments
----------- --------
MVI H,scrpg ; Set H to match scratch page (RAM)
MVI L,stwd ; Store floating-point number,
; starting at STWD.
MVI C,scr ; Scratch area
CALL input ;
The resulting floating-point number has three 8-bit words of
mantissa, and a fourth word that contains 6 bits of exponent, 1
bit for mantissa sign, and 1 bit for exponent sign (see Figure
1). Negative mantissa are indicated only by the sign bit, as the
mantissa itself is in sign-magnitude form. But the negative
exponents are in two's complement form.
Figure 1. Floating-point word format. This format allows
representation of numbers from ±6.46235 * 10 to the power of
-27 to ±4.61168 * 10 to the power of 18.
7 6 5 4 3 2 1 0
+-+-+-+-+-+-+-+-+
STWD | | | | | | | | | Most significant word
+-+-+-+-+-+-+-+-+
STWD<-1 | | | | | | | | |
+-+-+-+-+-+-+-+-+
STWD<-2 | | | | | | | | | Least significant word
+-+-+-+-+-+-+-+-+
STWD<-3 | | | | | | | | |
+-+-+-+-+-+-+-+-+
| |
| +--> Exponent sign: 1=negative, 0=positive
+----> Mantissa sign: 1=negative, 0=positive
If an addition (LADD) is wanted, place the pointer to one addend
in the L-register, the pointer to the other addend in the
B-register, and a pointer in the C-register. The C-register
points to a four-word scratch area used during the addition
process. The result is pointed to by the L-register (see Table
3).
Table 3. Assembly language setup for addition.
Program Comments
----------- --------
MVI H,scrpg ; Set H to match scratch page (RAM)
MVI L,add1 ; Pointer four-word addend and final result
MVI B,add2 ; Pointer 2nd four-word addend
MVI C,scr ; Four-word scratch area
CALL ladd ; Turn control over to addition routines
The subtraction (LSUB) routine is very similar to the addition
routine. The L-register holds the pointer to the minuend, and
the B-register holds the pointer to the subtrahend. The
C-register once again is used as a four-word scratch area, and
the result is placed in the area pointed to by the L-register,
destroying the previous data residing there (see Table 4).
Table 4. Assembly language setup for subtraction.
Program Comments
----------- --------
MVI H,scrpg ; Set H to match scratch page (RAM)
MVI L,sub1 ; Pointer four-word minuend and final result
MVI B,sub2 ; Pointer to four-word subtraend
MVI C,scr ; Four-word scratch area
CALL lsub ; Turn control over to subtraction routines
If a multiplication (LMUL) is wanted, again use the L-, B-, and
C-registers. The pointer for the multiplicand resides in the
L-register, the pointer for the multiplier in the B-register,
and the pointer to the result in the C-register (see Table 5).
Table 5. Assembly language setup for multiplication.
Program Comments
----------- --------
MVI H,scrpg ; Set H to match scratch page (RAM)
MVI L,mlcan ; Pointer to four-word multiplicant
MVI B,mlplr ; Pointer to four-word multiplier
MVI C,rslt ; Four-word scratch area
CALL lmul ; Turn control over to multiply routines
Division (LDIV), like multiplication, uses the C-register to
hold the pointer to the result (quotient). The L-register
pointer refers to dividend, and the B-register pointer refers to
the divisor (see Table 6).
Table 6. Assembly language setup for division.
Program Comments
----------- --------
MVI H,scrpg ; Set H to match scratch page (RAM)
MVI L,dvdnd ; Pointer to four-word dividend
MVI B,dvsr ; Pointer to four-word divisor
MVI C,rslt ; Four-word scratch area
CALL ldiv ; Turn control over to divide routines
The square root routine (DSQRT) uses the L-register to point to
the number to be converted, the B-register to point to the final
converted number, and the C-register to point to a 14 (decimal)
word scratch area (see Table 7).
Table 7. Assembly language setup for square root.
Program Comments
----------- --------
MVI H,scrpg ; Set H to match scratch page (RAM)
MVI L,num ; Pointer to number to be converted
MVI B,dvsr ; Pointer to converted number
MVI C,scr ; 14 word scratch area
CALL dsqrt ; Turn control over to square root routine
The final routine is the output routine (CVRT). This routine
converts the binary floating-point number pointed to in the
L-register to its ASCII equivalent, and types it out on the
teletypewriter. This routine uses a 15 (decimal) word scratch
area pointed to by the C-register (see Table 8). The final data
is printed in scientific notation. The output routine, like the
INPUT routine, is easily modified to output its data to an
internal (memory) register for display on an LED display.
Table 8. Assembly language to set up OUTPUT routine for its
proper execution.
Program Comments
----------- --------
MVI H,scrpg ; Set H to match scratch page (RAM)
MVI L,outnm ; Number to be converted from floating
; to decimal, and printed in scientific
; notation on teletypewriter.
MVI C,scr ; 15 word scratch area
CALL cvrt ; Turn control over to convert routine
Table 9 gives a simple program that allows the user to check out
the various routines, and examine the various binary
floating-point numbers.
Table 9. Sample program that takes two operands from the
teletypewriter, divides them, and outputs the result to the
teletypewriter. This routine can be useful in becoming familiar
with the different routines in the Floating-Point Package.
Program Comments
------- --------
ORG 0940H Program starts at location 0940H
;
scrpg EQU 9 ; Scratch page is page 9
op1 EQU 0 ; Starting location of operand 1
op2 EQU op1+4 ; Starting location of operand 2
rsult EQU op2+4 ; Starting location of result
scr EQU rsult+4 ; Starting location of scratch area
MVI H,scrpg ; Set H register to RAM scratch page
MVI L,op1 ; Pointer to operand 1
MVI C,scr ; Scratch area
CALL input ; Input operand 1 from teletypewriter
MVI L,op2 ; Pointer to operand 2
MVI C,scr ; Scratch
CALL input ; Input operand 2 from teletypewriter
MVI L,op1 ; Operand-1 pointer in L-register
MVI B,op2 ; Operand-2 pointer in B-register
MVI C,rsult ; Result to C-register pointer
CALL ldiv ; Divide OP1 by OP2, and place result in RSULT
;
MVI L,rsult ; L-pointer now RSULT
MVI C,slr ; Scratch area
CALL cvrt ; Output number, starting in location RSULT,
; to teletypewriter.
;
HALT ; End
Acknowledgments
---------------
This package was based on a package purchased from David Mead of
Recognition System. Major modifications were made by Hal Brand,
to allow ASCII I/O and a triple-precision mantissa.
Overflow-underflow problems were resolved by Frank Olken. A
hardy thanks is given to Eugene Fisher for foreseeing the need
for such a package.
Appendix: Source listing of Floating-Point Package
--------------------------------------------------
(To be done)
EOF