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_r2.txt < prev    next >
Internet Message Format  |  2009-12-11  |  8KB

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