1: / C library -- unprintf 2: 3: 4: .globl _unprintf 5: .globl ndigix 6: 7: .globl pfloat 8: .globl pscien 9: .globl _IEH3revp 10: .globl _IEH3bcko 11: 12: _unprintf: 13: mov r5,-(sp) 14: mov sp,r5 15: mov 4(r5),formp / format 16: mov r5,r4 17: add $6,r4 / arglist 18: sub $128.,sp / buffer 19: loop: 20: movb *formp,r0 21: beq 1f 22: inc formp 23: cmp r0,$'% 24: beq 2f 25: 3: 26: mov r4,-(sp) 27: mov r0,-(sp) 28: jsr pc,*$_IEH3revp 29: tst (sp)+ 30: mov (sp)+,r4 31: br loop 32: 1: 33: add $128.,sp 34: mov (sp)+,r5 35: jsr pc,_IEH3bcko 36: rts pc 37: 2: 38: clr rjust 39: clr ndigix 40: cmpb *formp,$'- 41: bne 2f 42: inc formp 43: inc rjust 44: 2: 45: jsr r3,gnum; width 46: clr ndfnd 47: cmp r0,$'. 48: bne 1f 49: jsr r3,gnum; ndigix 50: 1: 51: mov sp,r3 52: mov $swtab,r1 53: 1: 54: mov (r1)+,r2 55: beq 3b 56: cmp r0,(r1)+ 57: bne 1b 58: jmp (r2) 59: swtab: 60: decimal; 'd 61: octal; 'o 62: float; 'f 63: scien; 'e 64: charac; 'c 65: string; 's 66: logical; 'l 67: 0; 0 68: 69: decimal: 70: mov (r4)+,r1 71: bge 1f 72: neg r1 73: movb $'-,(r3)+ 74: br 1f 75: 76: logical: 77: mov (r4)+,r1 78: 1: 79: jsr pc,1f 80: br prbuf 81: 1: 82: clr r0 83: div $10.,r0 84: mov r1,-(sp) 85: mov r0,r1 86: beq 1f 87: jsr pc,1b 88: 1: 89: mov (sp)+,r0 90: add $'0,r0 91: movb r0,(r3)+ 92: rts pc 93: 94: charac: 95: movb (r4)+,(r3)+ 96: bne 1f 97: dec r3 98: 1: 99: movb (r4)+,(r3)+ 100: br prbuf 101: 102: string: 103: mov ndigix,r1 104: 1: 105: mov (r4)+,r2 106: 1: 107: movb (r2)+,(r3)+ 108: beq prbuf 109: sob r1,1b 110: br prbuf 111: 112: octal: 113: mov (r4)+,r1 114: jsr pc,1f 115: br prbuf 116: 1: 117: mov r1,-(sp) 118: beq 1f 119: ash $-3,r1 120: bic $!17777,r1 121: jsr pc,1b 122: 1: 123: mov (sp)+,r0 124: bic $!7,r0 125: add $'0,r0 126: movb r0,(r3)+ 127: rts pc 128: 129: float: 130: mov ndfnd,r2 131: jsr pc,pfloat 132: br prbuf 133: 134: scien: 135: mov ndfnd,r2 136: jsr pc,pscien 137: br prbuf 138: 139: prbuf: 140: cmp r3,sp 141: blos 1f 142: tstb -1(r3) 143: bne 1f 144: dec r3 145: br prbuf 146: 1: 147: mov sp,r2 148: mov r4,-(sp) 149: mov $' ,-(sp) 150: mov width,r1 151: sub r3,r1 152: clrb (r3)+ 153: add r2,r1 154: mov r1,spaces 155: ble 1f 156: tst rjust 157: bne 1f 158: 2: 159: jsr pc,*$_IEH3revp 160: dec spaces 161: bne 2b 162: 1: 163: mov r2,bufp 164: 1: 165: movb *bufp,(sp) 166: beq 1f 167: inc bufp 168: jsr pc,*$_IEH3revp 169: br 1b 170: 1: 171: tst spaces 172: ble 1f 173: tst rjust 174: beq 1f 175: mov $' ,(sp) 176: 2: 177: jsr pc,*$_IEH3revp 178: dec spaces 179: bne 2b 180: 1: 181: tst (sp)+ 182: mov (sp)+,r4 183: jmp loop 184: 185: gnum: 186: clr ndfnd 187: clr r1 188: 1: 189: movb *formp,r0 190: inc formp 191: sub $'0,r0 192: cmp r0,$9. 193: bhi 1f 194: inc ndfnd 195: mul $10.,r1 196: add r0,r1 197: br 1b 198: 1: 199: add $'0,r0 200: mov r1,*(r3)+ 201: rts r3 202: 203: .bss 204: ndigix: .=.+2 205: width: .=.+2 206: formp: .=.+2 207: rjust: .=.+2 208: ndfnd: .=.+2 209: bufp: .=.+2 210: spaces: .=.+2