home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / DRI-archive / roche / lllfp_roche.txt < prev    next >
Internet Message Format  |  2009-12-11  |  12KB

  1. From: French Luser
  2. newsgroup: comp.os.cpm
  3. Date: Wed, 27 Sep 2006 13:37:14 +0200
  4. Subject: Lawrence Livermore Laboratory Floating-Point Package doc
  5.  
  6.  
  7. LLLFP.WS4
  8. ---------
  9.  
  10. Lawrence Livermore Laboratory Floating-Point (LLLFP) package
  11.  
  12. Original title:
  13.  
  14. - "Floating-Point Package for Intel 8008 and 8080 Microprocessors"
  15.    Michael D. Maples
  16.    Lawrence Livermore Laboratory,
  17.    University of California/Livermore, California 94550,
  18.    October 24, 1975
  19.  
  20. (Retyped by Emmanuel ROCHE.)
  21.  
  22. UCRL-51940
  23. Work  performed  under the  auspices of  the U.S.  Department of
  24. Energy   by   Lawrence  Livermore   Laboratory  under   Contract
  25. W-7405-ENG-48.
  26. Distribution Category: UC-32
  27.  
  28.  
  29. Contents
  30. --------
  31.  
  32. Abstract
  33. Introduction
  34. Selection and use of operations
  35. Acknowledgments
  36. Appendix: Source listing of Floating-Point Package
  37.  
  38.  
  39. Abstract
  40. --------
  41.  
  42. The Lawrence Livermore Laboratory has used a scientific-notation
  43. mathematics package that performs Floating-Point arithmetic with
  44. Intel 8008 and 8080 microprocesors.  The execution times for the
  45. mathematical operations --  add, subtract, multiply, divide, and
  46. square root -- range from 3 to 77 ms. Instructions for using the
  47. Floating-Point Package and a source listing of it are included.
  48.  
  49.  
  50. Introduction
  51. ------------
  52.  
  53. For the last two years, Lawrence Livermore Laboratory has used a
  54. scientific-notation mathematics package (Floating-Point Package)
  55. with  the  Intel 8008  and 8080  microprocessors.  This  package
  56. allows  addition,  subtraction,  multiplication,  division,  and
  57. square root operations.  Table 1 shows  the execution  times for
  58. these  operations.  The  program  listing of  the complete  8080
  59. Floating-Point Package is in the Appendix. The package uses some
  60. I/O calls from an octal debug  routine (ODT)  that has  become a
  61. standard part of all inhouse LLL  microcomputers, but  this need
  62. not be necessary.  The appropriate ODT calls (6 or 7) in the I/O
  63. routines   can   easily   be   replaced  by   assembly  language
  64. equivalents.
  65.  
  66.  
  67. Table 1. Worst-case execution times for the 8080  microprocessor
  68. using a 0.5-us clock with the package in  programmable read-only
  69. memory (PROM)
  70.  
  71. Operation  Execution times (ms)
  72. ---------  --------------------
  73. Add                 3
  74. Subtract            3
  75. Multiply            7
  76. Divide              8
  77. Square root        77
  78.  
  79. The  Floating-Point  Package  uses  24  bits  of  mantissa   for
  80. approximately  7-1/2  digits of  accuracy in  expressing numeric
  81. data.  Obviously, this decreases rapidly when  complex iterative
  82. computations are used.  Nevertheless, the package is functioning
  83. quite  satisfactorily   in  many   experiments,  with   accuracy
  84. requirements of one part per hundred thousand.
  85.  
  86. The package also indicates underflows and overflows, by  placing
  87. zeros in the mantissa and a 64 (decimal) in the exponent word.
  88.  
  89.  
  90. Selection and use of operations
  91. -------------------------------
  92.  
  93. All  registers  described  in  this  paper  points to  four-word
  94. internal mathematical  storage areas,  unless otherwise  stated.
  95. Also, before performing any  mathematical operation,  all needed
  96. operands must be placed in the same random access memory  (RAM),
  97. along with any needed scratch areas  (i.e., all  must reside  in
  98. the same page of  RAM). (ROCHE>  Obviously, the  author of  this
  99. paper has NOT the same idea  of what  is a  "page" and  a "word"
  100. than me...)
  101.  
  102. The first problem is  how to  get the  decimal numbers  into the
  103. correct  format  for  use  in the  Floating-Point Package.   The
  104. routine  INPUT  performs the  conversion for  all teletypewriter
  105. input.  Also,  it easily  adapts to  converting any  BCD numeric
  106. inputs  from  either digital  panel meters  (DPM) or  thumbwheel
  107. switches.  To  use INPUT,  set the  L-register to  point at  the
  108. location in  RAM where  the result  of the  conversion is  to be
  109. placed, and set the C-register to point to  another location  in
  110. RAM where intermediate steps are to be calculated.   Then, do  a
  111. call to the INPUT routine that  does the  appropriate conversion
  112. (see Table 2).
  113.  
  114. Table 2.  Program for using INPUT routine. The  scratch area  is
  115. 15 (decimal)  bytes long,  but the  converted number  is only  4
  116. bytes long.
  117.  
  118.         Program         Comments
  119.         -----------     --------
  120.         MVI H,scrpg     ; Set H to match scratch page (RAM)
  121.         MVI L,stwd      ; Store floating-point number,
  122.                         ;   starting at STWD.
  123.         MVI C,scr       ; Scratch area
  124.         CALL input      ;
  125.  
  126. The resulting  floating-point number  has three  8-bit words  of
  127. mantissa, and a fourth word that contains 6 bits of  exponent, 1
  128. bit for mantissa sign, and 1 bit for  exponent sign  (see Figure
  129. 1). Negative mantissa are indicated only by the sign bit, as the
  130. mantissa itself  is in  sign-magnitude form.   But the  negative
  131. exponents are in two's complement form.
  132.  
  133. Figure  1.   Floating-point  word  format.  This  format  allows
  134. representation of numbers from ▒6.46235 * 10 to  the power  of
  135. -27 to ▒4.61168 * 10 to the power of 18.
  136.  
  137.          7 6 5 4 3 2 1 0
  138.         +-+-+-+-+-+-+-+-+
  139. STWD    | | | | | | | | | Most significant word
  140.         +-+-+-+-+-+-+-+-+
  141. STWD<-1 | | | | | | | | |
  142.         +-+-+-+-+-+-+-+-+
  143. STWD<-2 | | | | | | | | | Least significant word
  144.         +-+-+-+-+-+-+-+-+
  145. STWD<-3 | | | | | | | | |
  146.         +-+-+-+-+-+-+-+-+
  147.          | |
  148.          | +--> Exponent sign: 1=negative, 0=positive
  149.          +----> Mantissa sign: 1=negative, 0=positive
  150.  
  151. If an addition (LADD) is wanted, place the pointer to one addend
  152. in  the  L-register,  the  pointer to  the other  addend in  the
  153. B-register,  and  a pointer  in the  C-register. The  C-register
  154. points  to  a four-word  scratch area  used during  the addition
  155. process. The result is pointed to by the  L-register (see  Table
  156. 3).
  157.  
  158. Table 3. Assembly language setup for addition.
  159.  
  160.         Program         Comments
  161.         -----------     --------
  162.         MVI H,scrpg     ; Set H to match scratch page (RAM)
  163.         MVI L,add1      ; Pointer four-word addend and final result
  164.         MVI B,add2      ; Pointer 2nd four-word addend
  165.         MVI C,scr       ; Four-word scratch area
  166.         CALL ladd       ; Turn control over to addition routines
  167.  
  168. The subtraction (LSUB) routine is very  similar to  the addition
  169. routine. The L-register holds  the pointer  to the  minuend, and
  170. the  B-register  holds  the  pointer  to  the  subtrahend.   The
  171. C-register once again is used as a four-word  scratch area,  and
  172. the result is placed in the area pointed  to by  the L-register,
  173. destroying the previous data residing there (see Table 4).
  174.  
  175. Table 4. Assembly language setup for subtraction.
  176.  
  177.         Program         Comments
  178.         -----------     --------
  179.         MVI H,scrpg     ; Set H to match scratch page (RAM)
  180.         MVI L,sub1      ; Pointer four-word minuend and final result
  181.         MVI B,sub2      ; Pointer to four-word subtraend
  182.         MVI C,scr       ; Four-word scratch area
  183.         CALL lsub       ; Turn control over to subtraction routines
  184.  
  185. If a multiplication (LMUL) is wanted, again use the L-,  B-, and
  186. C-registers. The  pointer for  the multiplicand  resides in  the
  187. L-register, the pointer for  the multiplier  in the  B-register,
  188. and the pointer to the result in the C-register (see Table 5).
  189.  
  190. Table 5. Assembly language setup for multiplication.
  191.  
  192.         Program         Comments
  193.         -----------     --------
  194.         MVI H,scrpg     ; Set H to match scratch page (RAM)
  195.         MVI L,mlcan     ; Pointer to four-word multiplicant
  196.         MVI B,mlplr     ; Pointer to four-word multiplier
  197.         MVI C,rslt      ; Four-word scratch area
  198.         CALL lmul       ; Turn control over to multiply routines
  199.  
  200. Division  (LDIV),  like multiplication,  uses the  C-register to
  201. hold  the  pointer  to  the  result  (quotient). The  L-register
  202. pointer refers to dividend, and the B-register pointer refers to
  203. the divisor (see Table 6).
  204.  
  205. Table 6. Assembly language setup for division.
  206.  
  207.         Program         Comments
  208.         -----------     --------
  209.         MVI H,scrpg     ; Set H to match scratch page (RAM)
  210.         MVI L,dvdnd     ; Pointer to four-word dividend
  211.         MVI B,dvsr      ; Pointer to four-word divisor
  212.         MVI C,rslt      ; Four-word scratch area
  213.         CALL ldiv       ; Turn control over to divide routines
  214.  
  215. The square root routine (DSQRT) uses the L-register to point  to
  216. the number to be converted, the B-register to point to the final
  217. converted number, and the C-register to point to a 14  (decimal)
  218. word scratch area (see Table 7).
  219.  
  220. Table 7. Assembly language setup for square root.
  221.  
  222.         Program         Comments
  223.         -----------     --------
  224.         MVI H,scrpg     ; Set H to match scratch page (RAM)
  225.         MVI L,num       ; Pointer to number to be converted
  226.         MVI B,dvsr      ; Pointer to converted number
  227.         MVI C,scr       ; 14 word scratch area
  228.         CALL dsqrt      ; Turn control over to square root routine
  229.  
  230. The final  routine is  the output  routine (CVRT).  This routine
  231. converts  the  binary floating-point  number pointed  to in  the
  232. L-register to  its  ASCII equivalent,  and types  it out  on the
  233. teletypewriter. This routine uses  a 15  (decimal) word  scratch
  234. area pointed to by the C-register (see Table 8).  The final data
  235. is printed in scientific notation. The output routine,  like the
  236. INPUT  routine,  is easily  modified to  output its  data to  an
  237. internal (memory) register for display on an LED display.
  238.  
  239. Table 8. Assembly language to set up OUTPUT routine for its
  240. proper execution.
  241.  
  242.         Program         Comments
  243.         -----------     --------
  244.         MVI H,scrpg     ; Set H to match scratch page (RAM)
  245.         MVI L,outnm     ; Number to be converted from floating
  246.                         ;   to decimal, and printed in scientific
  247.                         ;   notation on teletypewriter.
  248.         MVI C,scr       ; 15 word scratch area
  249.         CALL cvrt       ; Turn control over to convert routine
  250.  
  251. Table 9 gives a simple program that allows the user to check out
  252. the   various   routines,   and   examine  the   various  binary
  253. floating-point numbers.
  254.  
  255. Table  9.   Sample  program  that  takes  two operands  from the
  256. teletypewriter,  divides  them, and  outputs the  result to  the
  257. teletypewriter. This routine can be useful in becoming  familiar
  258. with the different routines in the Floating-Point Package.
  259.  
  260.         Program         Comments
  261.         -------         --------
  262.         ORG 0940H       Program starts at location 0940H
  263.         ;
  264.         scrpg EQU 9     ; Scratch page is page 9
  265.         op1 EQU 0       ; Starting location of operand 1
  266.         op2 EQU op1+4   ; Starting location of operand 2
  267.         rsult EQU op2+4 ; Starting location of result
  268.         scr EQU rsult+4 ; Starting location of scratch area
  269.         MVI H,scrpg     ; Set H register to RAM scratch page
  270.         MVI L,op1       ; Pointer to operand 1
  271.         MVI C,scr       ; Scratch area
  272.         CALL input      ; Input operand 1 from teletypewriter
  273.         MVI L,op2       ; Pointer to operand 2
  274.         MVI C,scr       ; Scratch
  275.         CALL input      ; Input operand 2 from teletypewriter
  276.         MVI L,op1       ; Operand-1 pointer in L-register
  277.         MVI B,op2       ; Operand-2 pointer in B-register
  278.         MVI C,rsult     ; Result to C-register pointer
  279.         CALL ldiv       ; Divide OP1 by OP2, and place result in RSULT
  280.         ;
  281.         MVI L,rsult     ; L-pointer now RSULT
  282.         MVI C,slr       ; Scratch area
  283.         CALL cvrt       ; Output number, starting in location RSULT,
  284.                         ;   to teletypewriter.
  285.         ;
  286.         HALT            ; End
  287.  
  288.  
  289. Acknowledgments
  290. ---------------
  291.  
  292. This package was based on a package purchased from David Mead of
  293. Recognition System.  Major modifications were made by Hal Brand,
  294. to   allow   ASCII   I/O   and   a   triple-precision  mantissa.
  295. Overflow-underflow  problems  were resolved  by Frank  Olken.  A
  296. hardy thanks is given to Eugene Fisher for  foreseeing the  need
  297. for such a package.
  298.  
  299.  
  300. Appendix: Source listing of Floating-Point Package
  301. --------------------------------------------------
  302.  
  303. (To be done)
  304.  
  305.  
  306. EOF
  307.  
  308.  
  309.  
  310.