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 / FALCONER.TXT < prev    next >
Text File  |  2009-12-11  |  7KB  |  149 lines

  1. "Falconer Floating Point Arithmetic"
  2. by Charles Falconer,
  3.    formerly Chief Instrumentation Engineer, Yale University
  4.    http://www.qwikpages.com/backstreets/cbfalconer
  5. in DDJ, March 1979, p.4 and April 1979, p.16
  6.  
  7. This software package provides full floating point arithmetic
  8. capability for 8080, 8085, and Z80-based machines, with very
  9. little speed penalty over use of integer arithmetic. The system
  10. can handle all 16-bit integer values (treated either as positive
  11. integers in the range 0 to 65535, or as signed integers in the
  12. range -32768 to 32767) without any loss of information, yet the
  13. extended range (approximately 10^-38 to 10^+38) convenience of
  14. floating point is directly available, together with various
  15. mathematical functions (i.e., logarithms, exponentials, etc). I
  16. hope that this publication will discourage use of integer
  17. arithmetic in various interpreters, compilers, etc.
  18.  
  19. The operand size is such as to allow virtually all inner loops to
  20. be performed entirely in registers, with attendant speed benefits.
  21. At  a 518 nanoseconds clock, most arithmetic operations are
  22. performed in one millisecond or less, division in about 1.5
  23. milliseconds. A 4-MHz Z80 system can halve this. This is not far
  24. removed from integer execution times.
  25.  
  26. I strongly recommend that any user of this package do so without
  27. any alteration (except deletion of routines not needed in the
  28. application). This system has been in routine operation since
  29. April 1976, and is incorporated in other systems. The least
  30. exercised routines are in FLTINPUT and FUNCTION.
  31.  
  32. While the calling convention to IVAL, for example, may appear
  33. unusual, it has been specifically designed to allow re-entrant use
  34. with various data sources. A calling routine of the form:
  35.  
  36.         GETNUM: PUSH    B
  37.                 LXI     B,(address of char input routine)
  38.                 CALL    IVAL    ; (or IVALC)
  39.                 POP     B
  40.                 RET
  41.  
  42. will customize this as required and will avoid conflict with any
  43. other software.
  44.  
  45. The system does not have the awkward range limitation of the EA
  46. chip (approximately 10^-18 to 10^+18) and some other systems,
  47. which I have found to bite the user all too often. Due to the
  48. careful treatment of rounding and over/underflow, the system will
  49. usually give the expected results (inversion of large matrices is
  50. the only exception noted so far, yet systems of 5 to 10
  51. simultaneous equations, on our typical input data, can be handled
  52. adequately), and the error and overflow reporting will provide
  53. adequate warnings of runtime misuse. Error analysis is
  54. mathematically tractable.
  55.  
  56. The AERC (arithmetic error connector) allows trappings of illegal
  57. operands (division by zero, logarithm of negative number, etc). If
  58. desired, this can be specified a:
  59.  
  60.         AERC:   STC
  61.                 RET
  62.  
  63. which will cause all such occurrences to be treated as overflows.
  64.  
  65. In general, any error is signaled by Carry set on routine exit.
  66. The individual routine functions are stated in the commentary, and
  67. registers disturbed are listed.
  68.  
  69. Notice that the unspecified I/O routines output register C, and
  70. return with A set to C on entry. Input routines return characters
  71. in A.
  72.  
  73. Also, notice that all routines (except those specifically using
  74. I/O devices) are re-entrant, and use only stack-assigned temporary
  75. storage. The code is thus inherently suitable for the time sharing
  76. or interrupt driven applications. Users who have been using
  77. integer arithmetic may find that extra stack space must be
  78. allocated. An extra 32 bytes should normally suffice.
  79.  
  80. For the benefit of readers without a macro-assembler, macros used
  81. generally depend on the definition of registers as B=0, C=1, D=2,
  82. E=3, H=4, L=5, M=SP=PSW=6, A=7. Between the macro definitions and
  83. the actual code generated, users should be able to substitute
  84. suitable source code. Our assembler permits "@" and  "." in names,
  85. automatically increments and decrements the global variable ".LVL"
  86. on each PUSH and POP instruction, respectively, and can generate
  87. relocatable code. Source code between IF and ENDIF statements is
  88. assembled only if the IF operand is non-zero, and between IFZ and
  89. ENDIF only if the IFZ operand is zero. This listing uses this
  90. construct only within macros. The "EXTRN" lists show external
  91. addresses required within a module, and the "ENTRY" lists show
  92. address required by other modules. Note that some character
  93. constants may be in lower case (and are so marked). The printer
  94. used translated these to upper case. This should be sufficient to
  95. allow the user to customize the source to his assembler.
  96.  
  97. I originally intended to submit listings with all macros fully
  98. expanded, but the results were excessively cluttered, no longer
  99. held any clarity, and the listing length was virtually doubled. As
  100. submitted, all information remains present, but the reader may
  101. have to refer to the macro definitions fairly often.
  102.  
  103. The load map below shows the location of all routines when loaded
  104. at location 1000H up, in the order shown. The "U" identifies
  105. labels undefined in the overall system.
  106.  
  107. Historically, this system replaced an earlier design (published in
  108. the Intel User Library) which used 2's complement mantissas and
  109. exponents. That system had 1 less bit of resolution, control of
  110. negative extremes and rounding had a problem, and was 5 to 10
  111. times slower than the present system.
  112.  
  113. Load Map
  114. --------
  115.  
  116.   Code     Data  Name
  117. ---------  ----  ----
  118. 1000-115A  None  INTARITH.ASM
  119. 115B-1463  None  FLTARITH.ASM
  120. 1464-15BB  None  FLTINPUT.ASM
  121. 15BC-17D2  None  FLTOUT.ASM
  122. 17D3-19FA  None  FUNCTION.ASM
  123.  
  124.   .AND    1986    .EQU    19A6    .GE.    19D7    .GG.    19E0
  125.   .GT.    19C5    .LE.    19BC    .LT.    19CE    .NE.    19AF
  126.   .OR.    1971    .XOR    1996  U-AERC    0000    BCLC    102B
  127.   BCLZ    102A    BCRA    1032    BCRC    1034    C1BC    1045
  128.   C1DE    104D    C2BC    1044    C2DE    104C    C2DHL   1054
  129. U-COUT    0000    DEBLK   1479    DERA    103B    DERC    103D
  130.   DHLZ    1022    DIV     1114    DQUIK   1082    DTEN    106A
  131.   EXDG    15FF    EXP2    18E1    EXPX    1931    FADD    1303
  132.   FCMP    1387    FDIV    1248    FDIVR   12A5    FDIVT   1202
  133.   FINT    13DC    FIXR    1439    FIXT    1404    FLOAD   11DC
  134.   FLOT    13E1    FLOTA   13B9    FLOTD   13D7    FLOTP   13CE
  135.   FMAT    172B    FMOD    17EE    FMUL    1210    FMULT   11F4
  136.   FRACT   17D3    FRCIP   12B1    FSTOR   11E8    FSUB    137A
  137.   FSUBR   12FF    FXCHG   11B5    IDIV    10A7    IMUL    108A
  138.   IVAL    1482    IVALC   14B5    JBC     1477    LAS     101A
  139.   LBCS    1011    LDES    1008    LFBIS   11A9    LFBS    119C
  140.   LFDIS   11B9    LFDS    11BF    LFLT    170C    LOG2    1B23
  141.   LOGB    188C  U-LOUT    0000    MUL     10D9    MUL10   1061
  142.   MLRD    115B    DDZS    15E1    DFLT    171C    ONEG    15DC
  143.   OPT     15D7    DTCBK   15BC    DTCCL   15BE    POLY    1BAB
  144.   QMAX    146B    QNUM    1464    SFDIS   11C9    STADR   1000
  145.   TFLT    1714
  146.  
  147.  
  148. EOF
  149.