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

Defined functions

_atof declared in line 4; defined in line 13; used 1 times
  • in line 4
charac defined in line 146; used 1 times
  • in line 67
decimal defined in line 75; used 1 times
  • in line 62
fltused declared in line 4; defined in line 14; used 1 times
  • in line 4
gnum defined in line 261; used 2 times
long defined in line 106; used 1 times
  • in line 86
longorunsg defined in line 82; used 1 times
  • in line 69
loop defined in line 23; used 2 times
pfloat declared in line 4; defined in line 15; used 1 times
  • in line 4
prbuf defined in line 226; used 4 times
prstr defined in line 230; used 1 times
pscien declared in line 4; defined in line 16; used 1 times
  • in line 4
string defined in line 156; used 1 times
  • in line 68
unsigned defined in line 88; used 1 times
  • in line 84

Defined variables

formp defined in line 286; used 7 times
ndigit defined in line 289; used 3 times
swtab defined in line 61; used 1 times
  • in line 53
width defined in line 285; used 2 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2501
Valid CSS Valid XHTML 1.0 Strict