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

Defined variables

_atof declared in line 5; defined in line 14; used 1 times
  • in line 5
_printf declared in line 4; defined in line 18; used 1 times
  • in line 4
charac defined in line 147; used 1 times
  • in line 68
decimal defined in line 76; used 1 times
  • in line 63
fltused declared in line 5; defined in line 15; used 1 times
  • in line 5
formp defined in line 287; used 7 times
gnum defined in line 262; used 2 times
long defined in line 107; used 1 times
  • in line 87
longorunsg defined in line 83; used 1 times
  • in line 70
loop defined in line 24; used 2 times
ndigit defined in line 290; used 3 times
pfloat declared in line 5; defined in line 16; used 1 times
  • in line 5
prbuf defined in line 227; used 4 times
prstr defined in line 231; used 1 times
pscien declared in line 5; defined in line 17; used 1 times
  • in line 5
string defined in line 157; used 1 times
  • in line 69
swtab defined in line 62; used 1 times
  • in line 54
unsigned defined in line 89; used 1 times
  • in line 85
width defined in line 286; used 2 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1062
Valid CSS Valid XHTML 1.0 Strict