1: ldfps = 170100^tst
   2: stfps = 170200^tst
   3: / ftoa -- basic g fp conversion
   4: 
   5: .globl  _ndigit
   6: .globl ecvt
   7: .globl fcvt
   8: 
   9: 
  10: / ecvt converts fr0 into decimal
  11: / the string of converted digits is pointed to by r0.
  12: / the number of digits are specified by _ndigit
  13: / r2 contains the decimal point
  14: / r1 contains the sign
  15: 
  16: .globl  _ecvt, _fcvt
  17: 
  18: _ecvt:
  19:         mov     r5,-(sp)
  20:         mov     sp,r5
  21:         mov     r2,-(sp)
  22:         movf    4(r5),fr0
  23:         mov     14(r5),_ndigit
  24:         jsr     pc,ecvt
  25:         br      1f
  26: 
  27: _fcvt:
  28:         mov     r5,-(sp)
  29:         mov     sp,r5
  30:         mov     r2,-(sp)
  31:         movf    4(r5),fr0
  32:         mov     14(r5),_ndigit
  33:         jsr     pc,fcvt
  34: 1:
  35:         mov     r2,*16(r5)
  36:         mov     r1,*20(r5)
  37:         mov     (sp)+,r2
  38:         mov     (sp)+,r5
  39:         rts     pc
  40: 
  41: fcvt:
  42:         clr     eflag
  43:         br      1f
  44: ecvt:
  45:         mov     $1,eflag
  46: 1:
  47:         stfps   -(sp)
  48:         ldfps   $200
  49:         movf    fr0,-(sp)
  50:         movf    fr1,-(sp)
  51:         mov     r3,-(sp)
  52:         mov     $buf,r1
  53:         clr     r2
  54:         clr     sign
  55:         tstf    fr0
  56:         cfcc
  57:         beq     zer
  58:         bgt     1f
  59:         inc     sign
  60:         negf    fr0
  61: 1:
  62:         modf    $one,fr0
  63:         tstf    fr1
  64:         cfcc
  65:         beq     lss
  66: 
  67: gtr:
  68:         movf    fr0,-(sp)
  69:         movf    fr1,fr0
  70: 1:
  71:         mov     $buftop,r3
  72: 1:
  73:         modf    tenth,fr0
  74:         movf    fr0,fr2
  75:         movf    fr1,fr0
  76:         addf    $epsilon,fr2
  77:         modf    $ten,fr2
  78:         movfi   fr3,r0
  79:         add     $'0,r0
  80:         movb    r0,-(r3)
  81:         inc     r2
  82:         tstf    fr0
  83:         cfcc
  84:         bne     1b
  85: /
  86:         mov     $buf,r1
  87: 1:
  88:         movb    (r3)+,(r1)+
  89:         cmp     r3,$buftop
  90:         blo     1b
  91: /
  92:         movf    (sp)+,fr0
  93:         br      pad
  94: 
  95: zer:
  96:         inc     r2
  97:         br      pad
  98: 
  99: lss:
 100:         dec     r2
 101:         modf    $ten,fr0
 102:         tstf    fr1
 103:         cfcc
 104:         beq     lss
 105:         inc     r2
 106:         jsr     pc,digit1
 107: 
 108: pad:
 109:         jsr     pc,digit
 110:                 br out
 111:         br      pad
 112: 
 113: digit:
 114:         cmp     r1,$buftop
 115:         bhis    1f
 116:         add     $2,(sp)
 117:         modf    $ten,fr0
 118: 
 119: digit1:
 120:         movfi   fr1,r0
 121:         add     $'0,r0
 122:         movb    r0,(r1)+
 123: 1:
 124:         rts     pc
 125: /
 126: out:
 127:         mov     $buf,r0
 128:         add     _ndigit,r0
 129:         tst     eflag
 130:         bne     1f
 131:         add     r2,r0
 132: 1:
 133:         cmp     r0,$buf
 134:         blo     outout
 135:         movb    (r0),r3
 136:         add     $5,r3
 137:         movb    r3,(r0)
 138: 1:
 139:         cmpb    (r0),$'9
 140:         ble     1f
 141:         movb    $'0,(r0)
 142:         cmp     r0,$buf
 143:         blos    2f
 144:         incb    -(r0)
 145:         br      1b
 146: 2:
 147:         movb    $'1,(r0)
 148:         inc     r2
 149: 1:
 150: outout:
 151:         mov     sign,r1
 152:         mov     _ndigit,r0
 153:         tst     eflag
 154:         bne     1f
 155:         add     r2,r0
 156: 1:
 157:         clrb    buf(r0)
 158:         mov     $buf,r0
 159:         mov     (sp)+,r3
 160:         movf    (sp)+,fr1
 161:         movf    (sp)+,fr0
 162:         ldfps   (sp)+
 163:         rts     pc
 164: 
 165: epsilon = 037114
 166: one     = 40200
 167: ten     = 41040
 168:         .data
 169: tenth:  037314; 146314; 146314; 146315
 170: _ndigit:10.
 171:         .bss
 172: buf:    .=.+40.
 173: buftop:
 174: sign:   .=.+2
 175: eflag:  .=.+2
 176:         .text

Defined functions

_ecvt declared in line 16; defined in line 18; used 1 times
  • in line 16
_fcvt declared in line 16; defined in line 27; used 1 times
  • in line 16
digit defined in line 113; used 1 times
digit1 defined in line 119; used 1 times
ecvt declared in line 6; defined in line 44; used 9 times
epsilon defined in line 165; used 1 times
  • in line 76
fcvt declared in line 7; defined in line 41; used 7 times
gtr defined in line 67; never used
lss defined in line 99; used 2 times
one defined in line 166; used 1 times
  • in line 62
out defined in line 126; used 1 times
outout defined in line 150; used 1 times
pad defined in line 108; used 3 times
ten defined in line 167; used 3 times
zer defined in line 95; used 1 times
  • in line 57

Defined variables

_ndigit declared in line 5; defined in line 170; used 19 times
buf defined in line 172; used 7 times
buftop defined in line 173; used 3 times
eflag defined in line 175; used 4 times
sign defined in line 174; used 3 times
tenth defined in line 169; used 1 times
  • in line 73
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 622
Valid CSS Valid XHTML 1.0 Strict