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

Defined functions

__doprnt declared in line 19; defined in line 25; used 2 times
charac defined in line 225; used 1 times
  • in line 94
compute defined in line 173; used 1 times
decimal defined in line 142; used 1 times
  • in line 91
formp defined in line 14; used 12 times
gnum defined in line 278; used 2 times
hex defined in line 130; used 1 times
  • in line 93
lhex defined in line 134; used 2 times
loct defined in line 124; used 2 times
long defined in line 152; used 2 times
longorunsg defined in line 107; used 2 times
loop defined in line 30; used 2 times
lunsigned defined in line 163; used 2 times
ndfnd defined in line 16; used 3 times
ndigit defined in line 17; used 4 times
octal defined in line 121; used 1 times
  • in line 92
prbuf defined in line 256; used 4 times
prstr defined in line 258; used 1 times
remote defined in line 251; used 1 times
  • in line 99
rjust defined in line 15; used 3 times
string defined in line 233; used 1 times
  • in line 95
unsigned defined in line 148; used 2 times
width defined in line 13; used 2 times
zfill defined in line 18; used 5 times

Defined variables

nulstr defined in line 302; used 1 times
swtab defined in line 90; used 1 times
  • in line 79
Last modified: 1983-06-15
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 442
Valid CSS Valid XHTML 1.0 Strict