1: / assure fake printf (no floating)
   2: 
   3: .globl  fltused; fltused = 0
   4: 
   5: / convert stream to number; result is type.
   6: / value in cval or fcval
   7: 
   8: fpp = 1
   9: 
  10: .globl  _getnum
  11: 
  12: .globl  _peekc
  13: .globl  _getchar
  14: .globl  _cval
  15: .globl  _fcval
  16: .globl  _error
  17: 
  18: _getnum:
  19:         .if     fpp
  20:         movif   $10.,fr3
  21:         clrf    fr0
  22:         .endif
  23:         clr     nfract
  24:         clr     totdig
  25:         clr     decpt
  26:         clr     _cval
  27:         mov     2(sp),base
  28:         mov     r2,-(sp)
  29: 1:
  30:         jsr     r5,getdig
  31:                 br 2f
  32:         .if     fpp
  33:         mulf    fr3,fr0
  34:         movif   r0,fr1
  35:         addf    fr1,fr0
  36:         .endif
  37:         inc     nfract
  38:         br      1b
  39: 2:
  40:         tst     decpt
  41:         bne     1f
  42:         clr     nfract
  43:         cmp     r0,$'.
  44:         bne     1f
  45:         mov     pc,decpt
  46:         br      1b
  47: 1:
  48:         tst     totdig
  49:         beq     1f
  50:         cmp     r0,$'e
  51:         bne     1f
  52:         clr     -(sp)
  53:         clr     _cval
  54:         mov     pc,decpt
  55:         clr     _cval
  56:         mov     $10.,base
  57:         jsr     pc,_getchar
  58:         cmp     r0,$'+
  59:         beq     2f
  60:         cmp     r0,$'-
  61:         bne     3f
  62:         inc     (sp)
  63:         br      2f
  64: 3:
  65:         mov     r0,_peekc
  66: 2:
  67:         jsr     r5,getdig
  68:                 br 2f
  69:         br      2b
  70: 2:
  71:         tst     (sp)+
  72:         beq     2f
  73:         neg     _cval
  74: 2:
  75:         sub     _cval,nfract
  76: 1:
  77:         mov     r0,_peekc
  78:         tst     totdig
  79:         bne     1f
  80:         mov     $39.,r0         / "." operator
  81: 9:
  82:         mov     (sp)+,r2
  83:         rts     pc
  84: 1:
  85:         tst     decpt
  86:         bne     1f
  87:         mov     $21.,r0         / fixed constant
  88:         br      9b
  89: 1:
  90:         .if     fpp
  91:         movif   $1,fr2
  92:         mov     nfract,r2
  93:         mov     r2,-(sp)
  94:         beq     2f
  95:         bgt     1f
  96:         neg     r2
  97: 1:
  98:         mulf    fr3,fr2
  99:         sob     r2,1b
 100: 2:
 101:         tst     (sp)+
 102:         ble     1f
 103:         divf    fr2,fr0
 104:         br      2f
 105: 1:
 106:         mulf    fr2,fr0
 107: 2:
 108:         mov     $_fcval,r0
 109:         movf    fr0,(r0)
 110:         tst     (r0)+
 111:         tst     (r0)+
 112:         bne     1f
 113:         tst     (r0)+
 114:         bne     1f
 115:         tst     (r0)+
 116:         bne     1f
 117:         mov     $24.,r0
 118:         mov     _fcval,_cval
 119:         br      9b
 120: 1:
 121:         mov     $23.,r0
 122:         br      9b
 123:         .endif
 124:         .if     1-fpp
 125:         mov     $fperr,-(sp)
 126:         jsr     pc,_error
 127:         tst     (sp)+
 128:         mov     $21.,r0
 129:         br      9b
 130: fperr:  <No floating point!\0>; .even
 131:         .endif
 132: 
 133: getdig:
 134:         mov     _peekc,r0
 135:         beq     1f
 136:         clr     _peekc
 137:         br      2f
 138: 1:
 139:         jsr     pc,_getchar
 140: 2:
 141:         sub     $'0,r0
 142:         cmp     r0,$9.
 143:         bhi     1f
 144:         inc     totdig
 145:         mov     _cval,r1
 146:         mul     base,r1
 147:         add     r0,r1
 148:         mov     r1,_cval
 149:         tst     (r5)+
 150:         rts     r5
 151: 1:
 152:         add     $'0,r0
 153:         rts     r5
 154: 
 155: .bss
 156: base:   .=.+2
 157: nfract: .=.+2
 158: decpt:  .=.+2
 159: totdig: .=.+2

Defined functions

_getnum declared in line 10; defined in line 18; used 2 times
fltused declared in line 3; defined in line 3; used 1 times
  • in line 3
fperr defined in line 130; used 1 times
fpp defined in line 8; used 4 times
getdig defined in line 133; used 2 times

Defined variables

base defined in line 156; used 3 times
decpt defined in line 158; used 5 times
nfract defined in line 157; used 5 times
totdig defined in line 159; used 4 times
Last modified: 1975-07-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 618
Valid CSS Valid XHTML 1.0 Strict