1: / C library -- ascii to floating
   2: 
   3: /	f = atof(p)
   4: /	char *p;
   5: 
   6: ldfps = 170100^tst
   7: stfps = 170200^tst
   8: 
   9: .globl  _atof
  10: 
  11: .globl  csv, cret
  12: 
  13: _atof:
  14:         jsr     r5,csv
  15:         stfps   -(sp)
  16:         ldfps   $200
  17:         movf    fr1,-(sp)
  18:         clr     -(sp)
  19:         clrf    fr0
  20:         clr     r2
  21:         mov     4(r5),r3
  22: 1:
  23:         movb    (r3)+,r0
  24:         cmp     $' ,r0
  25:         beq     1b
  26:         cmpb    r0,$'-
  27:         bne     2f
  28:         inc     (sp)
  29: 1:
  30:         movb    (r3)+,r0
  31: 2:
  32:         sub     $'0,r0
  33:         cmp     r0,$9.
  34:         bhi     2f
  35:         jsr     pc,digit
  36:                 br 1b
  37:         inc     r2
  38:         br      1b
  39: 2:
  40:         cmpb    r0,$'.-'0
  41:         bne     2f
  42: 1:
  43:         movb    (r3)+,r0
  44:         sub     $'0,r0
  45:         cmp     r0,$9.
  46:         bhi     2f
  47:         jsr     pc,digit
  48:                 dec r2
  49:         br      1b
  50: 2:
  51:         cmpb    r0,$'E-'0
  52:         beq     3f
  53:         cmpb    r0,$'e-'0
  54:         bne     1f
  55: 3:
  56:         clr     r4
  57:         clr     r1
  58:         cmpb    (r3),$'-
  59:         bne     3f
  60:         inc     r4
  61:         inc     r3
  62: 3:
  63:         movb    (r3)+,r0
  64:         sub     $'0,r0
  65:         cmp     r0,$9.
  66:         bhi     3f
  67:         mul     $10.,r1
  68:         add     r0,r1
  69:         br      3b
  70: 3:
  71:         tst     r4
  72:         bne     3f
  73:         neg     r1
  74: 3:
  75:         sub     r1,r2
  76: 1:
  77:         movf    $one,fr1
  78:         mov     r2,-(sp)
  79:         beq     2f
  80:         bgt     1f
  81:         neg     r2
  82: 1:
  83:         cmp     r2,$38.
  84:         blos    1f
  85:         clrf    fr0
  86:         tst     (sp)+
  87:         bmi     out
  88:         movf    $huge,fr0
  89:         br      out
  90: 1:
  91:         mulf    $ten,fr1
  92:         sob     r2,1b
  93: 2:
  94:         tst     (sp)+
  95:         bge     1f
  96:         divf    fr1,fr0
  97:         br      2f
  98: 1:
  99:         mulf    fr1,fr0
 100:         cfcc
 101:         bvc     2f
 102:         movf    $huge,fr0
 103: 2:
 104: out:
 105:         tst     (sp)+
 106:         beq     1f
 107:         negf    fr0
 108: 1:
 109:         movf    (sp)+,fr1
 110:         ldfps   (sp)+
 111:         jmp     cret
 112: /
 113: /
 114: digit:
 115:         cmpf    $big,fr0
 116:         cfcc
 117:         blt     1f
 118:         mulf    $ten,fr0
 119:         movif   r0,fr1
 120:         addf    fr1,fr0
 121:         rts     pc
 122: 1:
 123:         add     $2,(sp)
 124:         rts     pc
 125: /
 126: /
 127: one     = 40200
 128: ten     = 41040
 129: big     = 56200
 130: huge    = 77777

Defined functions

_atof declared in line 9; defined in line 13; used 5 times
big defined in line 129; used 1 times
digit defined in line 114; used 2 times
huge defined in line 130; used 2 times
one defined in line 127; used 1 times
  • in line 77
out defined in line 104; used 2 times
ten defined in line 128; used 2 times
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 518
Valid CSS Valid XHTML 1.0 Strict