1: /*
   2:  * Copyright (c) 1987 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifdef LIBC_SCCS
   8:         <@(#)fltpr.s	5.4 (Berkeley) 6/3/87\0>
   9:         .even
  10: #endif LIBC_SCCS
  11: 
  12: /*
  13:  * Floating point output support for doprnt.
  14:  */
  15: #include "DEFS.h"
  16: 
  17: .data
  18: sign:   .=.+2
  19: digits: .=.+2
  20: decpt:  .=.+2
  21: .text
  22: 
  23: .globl  _ecvt, _fcvt, _gcvt
  24: 
  25: /*
  26:  * If the compiler notices any floating point type stuff going on in a
  27:  * C object, it automatically outputs a reference to the symbol "fltused"
  28:  * to force loading of this portion of the doprnt support.  If fltused is
  29:  * not defined the references to pgen, pfloat and pscien in doprnt will
  30:  * be satisfied by ffltpr.s (fake floating print).  This artifice saves 1056
  31:  * bytes of text and 98 bytes of data space at last count.
  32:  */
  33: .globl  fltused
  34: fltused:
  35: 
  36: #ifdef NONFP
  37: /*
  38:  * And yet another kludge: since only one module may satisfy the fltused
  39:  * reference and since we really want to do the same trick with the floating
  40:  * point interpreter, we have this module reference the symbol fpsim defined
  41:  * by the interpreter to drag it in too ... (sigh) See the file
  42:  * ../fpsim/README for the real dirt ...
  43:  */
  44: .globl  fpsim
  45: #endif
  46: 
  47: ASENTRY(pgen)
  48:         mov     r3,-(sp)
  49:         mov     r0,-(sp)
  50:         tst     r2
  51:         bne     1f
  52:         mov     $6,(sp)
  53: 1:
  54:         movf    (r4)+,fr0
  55:         movf    fr0,-(sp)
  56:         jsr     pc,_gcvt
  57:         add     $8+2+2,sp
  58: 1:
  59:         tstb    (r3)+
  60:         bne     1b
  61:         dec     r3
  62:         rts     pc
  63: 
  64: ASENTRY(pfloat)
  65:         mov     $sign,-(sp)
  66:         mov     $decpt,-(sp)
  67:         tst     r2
  68:         bne     1f
  69:         mov     $6,r0
  70: 1:
  71:         mov     r0,-(sp)
  72:         mov     r0,digits
  73:         movf    (r4)+,fr0
  74:         movf    fr0,-(sp)
  75:         jsr     pc,_fcvt
  76:         add     $8+2+2+2,sp
  77:         tst     sign
  78:         beq     1f
  79:         movb    $'-,(r3)+
  80: 1:
  81:         mov     decpt,r2
  82:         bgt     1f
  83:         movb    $'0,(r3)+
  84: 1:
  85:         mov     r2,r1
  86:         ble     1f
  87: 2:
  88:         movb    (r0)+,(r3)+
  89:         sob     r1,2b
  90: 1:
  91:         mov     digits,r1
  92:         beq     1f
  93:         movb    $'.,(r3)+
  94: 1:
  95:         neg     r2
  96:         ble     1f
  97: 2:
  98:         dec     r1
  99:         blt     1f
 100:         movb    $'0,(r3)+
 101:         sob     r2,2b
 102: 1:
 103:         tst     r1
 104:         ble     2f
 105: 1:
 106:         movb    (r0)+,(r3)+
 107:         sob     r1,1b
 108: 2:
 109:         rts     pc
 110: 
 111: ASENTRY(pscien)
 112:         mov     $sign,-(sp)
 113:         mov     $decpt,-(sp)
 114:         mov     r0,-(sp)
 115:         mov     r0,digits
 116:         tst     r2
 117:         bne     1f
 118:         mov     $6,(sp)
 119: 1:
 120:         movf    (r4)+,fr0
 121:         movf    fr0,-(sp)
 122:         jsr     pc,_ecvt
 123:         add     $8+2+2+2,sp
 124:         tst     sign
 125:         beq     1f
 126:         movb    $'-,(r3)+
 127: 1:
 128:         cmpb    (r0),$'0
 129:         bne     1f
 130:         inc     decpt
 131: 1:
 132:         movb    (r0)+,(r3)+
 133:         movb    $'.,(r3)+
 134:         mov     digits,r1
 135:         dec     r1
 136:         ble     1f
 137: 2:
 138:         movb    (r0)+,(r3)+
 139:         sob     r1,2b
 140: 1:
 141:         movb    $'e,(r3)+
 142:         mov     decpt,r2
 143:         dec     r2
 144:         mov     r2,r1
 145:         bge     1f
 146:         movb    $'-,(r3)+
 147:         neg     r1
 148:         br      2f
 149: 1:
 150:         movb    $'+,(r3)+
 151: 2:
 152:         clr     r0
 153:         div     $10.,r0
 154:         add     $'0,r0
 155:         movb    r0,(r3)+
 156:         add     $'0,r1
 157:         movb    r1,(r3)+
 158:         rts     pc

Defined functions

fltused declared in line 33; defined in line 34; used 1 times
  • in line 33
pfloat defined in line 64; used 2 times
pgen defined in line 47; used 2 times
pscien defined in line 111; used 2 times

Defined variables

decpt defined in line 20; used 5 times
digits defined in line 19; used 4 times
sign defined in line 18; used 4 times
Last modified: 1987-08-05
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1193
Valid CSS Valid XHTML 1.0 Strict