1: / C library -- conversions
   2: / Overlay modification -- wfj 8/80
   3: / stack frame is one word larger...
   4: /
   5: 
   6: / width=-8.
   7: / formp=-10.
   8: / rjust=-12.
   9: / ndfnd=-14.
  10: / ndigit=-16.
  11: / zfill=-18.
  12: width=-10.
  13: formp=-12.
  14: rjust=-14.
  15: ndfnd=-16.
  16: ndigit=-18.
  17: zfill=-20.
  18: .globl  __doprnt
  19: 
  20: .globl  pfloat
  21: .globl  pscien
  22: .globl  pgen
  23: 
  24: .globl  __strout
  25: .globl  csv
  26: .globl  cret
  27: 
  28: __doprnt:
  29:         jsr     r5,csv
  30:         sub     $128.+12.,sp
  31:         mov     4(r5),formp(r5)         / format
  32:         mov     6(r5),r4
  33: loop:
  34:         mov     sp,r3
  35:         mov     formp(r5),r1
  36: 2:
  37:         movb    (r1)+,r2
  38:         beq     2f
  39:         cmp     r2,$'%
  40:         beq     2f
  41:         movb    r2,(r3)+
  42:         br      2b
  43: 2:
  44:         mov     r1,formp(r5)
  45:         cmp     r3,sp
  46:         beq     2f
  47:         mov     sp,r0
  48:         mov     8(r5),-(sp)
  49:         clr     -(sp)
  50:         mov     r3,-(sp)
  51:         sub     r0,(sp)
  52:         mov     r0,-(sp)
  53:         jsr     pc,__strout
  54:         add     $8,sp
  55: 2:
  56:         tst     r2
  57:         bne     2f
  58:         jmp     cret
  59: 2:
  60:         mov     sp,r3
  61: 2:
  62:         clr     rjust(r5)
  63:         clr     ndigit(r5)
  64:         mov     $' ,zfill(r5)
  65:         cmpb    *formp(r5),$'-
  66:         bne     2f
  67:         inc     formp(r5)
  68:         inc     rjust(r5)
  69: 2:
  70:         cmpb    *formp(r5),$'0
  71:         bne     2f
  72:         mov     $'0,zfill(r5)
  73: 2:
  74:         jsr     r3,gnum
  75:         mov     r1,width(r5)
  76:         clr     ndfnd(r5)
  77:         cmp     r0,$'.
  78:         bne     1f
  79:         jsr     r3,gnum
  80:         mov     r1,ndigit(r5)
  81: 1:
  82:         mov     $swtab,r1
  83: 1:
  84:         mov     (r1)+,r2
  85:         bne     2f
  86:         movb    r0,(r3)+
  87:         jmp     prbuf
  88: 2:
  89:         cmp     r0,(r1)+
  90:         bne     1b
  91:         jmp     (r2)
  92:         .data
  93: swtab:
  94:         decimal;        'd
  95:         octal;          'o
  96:         hex;            'x
  97:         float;          'f
  98:         scien;          'e
  99:         general;        'g
 100:         charac;         'c
 101:         string;         's
 102:         longorunsg;     'l
 103:         longorunsg;     'L
 104:         unsigned;       'u
 105:         remote;         'r
 106:         long;           'D
 107:         loct;           'O
 108:         lhex;           'X
 109:         lunsigned;      'U
 110:         0;  0
 111:         .text
 112: 
 113: general:
 114:         mov     ndigit(r5),r0
 115:         mov     ndfnd(r5),r2
 116:         jsr     pc,pgen
 117:         jbr     prbuf
 118: 
 119: longorunsg:
 120:         movb    *formp(r5),r0
 121:         inc     formp(r5)
 122:         cmp     r0,$'o
 123:         beq     loct
 124:         cmp     r0,$'x
 125:         beq     lhex
 126:         cmp     r0,$'d
 127:         beq     long
 128:         cmp     r0,$'u
 129:         beq     lunsigned
 130:         dec     formp(r5)
 131:         br      unsigned
 132: 
 133: octal:
 134:         clr     r0
 135:         br      1f
 136: loct:
 137:         mov     (r4)+,r0
 138: 1:
 139:         mov     $8.,r2
 140:         br      2f
 141: 
 142: hex:
 143:         clr     r0
 144:         br      1f
 145: 
 146: lhex:
 147:         mov     (r4)+,r0
 148: 1:
 149:         mov     $16.,r2
 150: 2:
 151:         mov     (r4)+,r1
 152:         br      compute
 153: 
 154: decimal:
 155:         mov     (r4)+,r1
 156:         sxt     r0
 157:         bmi     3f
 158:         br      2f
 159: 
 160: unsigned:
 161:         clr     r0
 162:         br      1f
 163: 
 164: long:
 165:         mov     (r4)+,r0
 166:         bge     1f
 167:         mov     (r4)+,r1
 168: 3:
 169:         neg     r0
 170:         neg     r1
 171:         sbc     r0
 172:         movb    $'-,(r3)+
 173:         br      2f
 174: 
 175: lunsigned:
 176:         mov     (r4)+,r0
 177: 1:
 178:         mov     (r4)+,r1
 179: 2:
 180:         mov     $10.,r2
 181: 
 182: /
 183: / Algorithm courtesy Keith Davis
 184: /
 185: compute:
 186:         mov     r5,-(sp)
 187:         mov     r4,-(sp)
 188:         mov     r0,r4
 189:         mov     ndigit(r5),r0
 190:         mov     r1,r5
 191:         ashc    $0,r4
 192:         beq     1f
 193:         tst     r0
 194:         beq     1f
 195:         movb    $'0,(r3)+
 196: 1:
 197:         jsr     pc,1f
 198:         mov     (sp)+,r4
 199:         mov     (sp)+,r5
 200:         br      prbuf
 201: 
 202: 1:
 203:         clr     r0
 204:         mov     r4,r1
 205:         beq     2f
 206:         div     r2,r0
 207:         mov     r0,r4
 208:         mov     r1,r0
 209: 2:
 210:         mov     r5,r1
 211:         asl     r2
 212:         div     r2,r0
 213:         asr     r2
 214:         asl     r0
 215:         cmp     r2,r1
 216:         bgt     2f
 217:         sub     r2,r1
 218:         inc     r0
 219: 2:
 220:         mov     r1,-(sp)
 221:         mov     r0,r5
 222:         bne     2f
 223:         tst     r4
 224:         beq     1f
 225: 2:
 226:         jsr     pc,1b
 227: 1:
 228:         mov     (sp)+,r0
 229:         add     $'0,r0
 230:         cmp     r0,$'9
 231:         ble     1f
 232:         add     $'a-'0-10.,r0
 233: 1:
 234:         movb    r0,(r3)+
 235:         rts     pc
 236: 
 237: charac:
 238:         mov     $' ,zfill(r5)
 239:         mov     (r4)+,r0
 240:         bic     $!377,r0
 241:         beq     prbuf
 242:         movb    r0,(r3)+
 243:         br      prbuf
 244: 
 245: string:
 246:         mov     $' ,zfill(r5)
 247:         mov     ndigit(r5),r1
 248:         mov     (r4),r2
 249:         mov     r2,r3
 250:         bne     1f
 251:         mov     $nulstr,r2
 252:         mov     r2,r3
 253:         mov     r2,(r4)
 254: 1:
 255:         tstb    (r2)+
 256:         beq     1f
 257:         inc     r3
 258:         sob     r1,1b
 259: 1:
 260:         mov     (r4)+,r2
 261:         br      prstr
 262: 
 263: float:
 264:         mov     ndigit(r5),r0
 265:         mov     ndfnd(r5),r2
 266:         jsr     pc,pfloat
 267:         br      prbuf
 268: 
 269: scien:
 270:         mov     ndigit(r5),r0
 271:         inc     r0
 272:         tst     ndfnd(r5)
 273:         bne     1f
 274:         mov     $7,r0
 275: 1:
 276:         mov     pc,r2
 277:         jsr     pc,pscien
 278:         br      prbuf
 279: 
 280: remote:
 281:         mov     (r4)+,r4
 282:         mov     (r4)+,formp(r5)
 283:         jmp     loop
 284: 
 285: prbuf:
 286:         mov     sp,r2
 287: prstr:
 288:         sub     r2,r3
 289:         mov     width(r5),r1
 290:         sub     r3,r1
 291:         bge     1f
 292:         clr     r1
 293: 1:
 294:         tst     rjust(r5)
 295:         bne     1f
 296:         neg     r1
 297: 1:
 298:         mov     zfill(r5),-(sp)
 299:         mov     8(r5),-(sp)
 300:         mov     r1,-(sp)
 301:         mov     r3,-(sp)
 302:         mov     r2,-(sp)
 303:         jsr     pc,__strout
 304:         add     $10.,sp
 305:         jmp     loop
 306: 
 307: gnum:
 308:         clr     ndfnd(r5)
 309:         clr     r1
 310: 1:
 311:         movb    *formp(r5),r0
 312:         inc     formp(r5)
 313:         sub     $'0,r0
 314:         cmp     r0,$'*-'0
 315:         bne     2f
 316:         mov     (r4)+,r0
 317:         br      3f
 318: 2:
 319:         cmp     r0,$9.
 320:         bhi     1f
 321: 3:
 322:         inc     ndfnd(r5)
 323:         mul     $10.,r1
 324:         add     r0,r1
 325:         br      1b
 326: 1:
 327:         add     $'0,r0
 328:         rts     r3
 329: 
 330: .data
 331: nulstr:
 332:         <(null)\0>

Defined functions

__doprnt declared in line 18; defined in line 28; used 1 times
  • in line 18
charac defined in line 237; used 1 times
compute defined in line 185; used 1 times
decimal defined in line 154; used 1 times
  • in line 94
float defined in line 263; used 1 times
  • in line 97
formp defined in line 13; used 12 times
general defined in line 113; used 1 times
  • in line 99
gnum defined in line 307; used 2 times
hex defined in line 142; used 1 times
  • in line 96
lhex defined in line 146; used 2 times
loct defined in line 136; used 2 times
long defined in line 164; used 2 times
longorunsg defined in line 119; used 2 times
loop defined in line 33; used 2 times
lunsigned defined in line 175; used 2 times
ndfnd defined in line 15; used 6 times
ndigit defined in line 16; used 7 times
octal defined in line 133; used 1 times
  • in line 95
prbuf defined in line 285; used 7 times
prstr defined in line 287; used 1 times
remote defined in line 280; used 1 times
rjust defined in line 14; used 3 times
scien defined in line 269; used 1 times
  • in line 98
string defined in line 245; used 1 times
unsigned defined in line 160; used 2 times
width defined in line 12; used 2 times
zfill defined in line 17; used 5 times

Defined variables

nulstr defined in line 331; used 1 times
swtab defined in line 93; used 1 times
  • in line 82
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1091
Valid CSS Valid XHTML 1.0 Strict