1: .globl _pwril, _pwrite, csv, cret 2: .text 3: / 4: / pwril(w, lint) 5: / int w; 6: / long lint; 7: / 8: / This routine writes the character representation of lint 9: / in a field at least w characters wide using pwrite. 10: / 11: _pwril: 12: jsr r5,csv 13: mov r5,r3 14: add $6,r3 / 2(r3) = low, (r3) = high 15: mov sp,r2 16: sub $14.,sp 17: clr (r2) 18: mov (r3),r1 19: bpl pwril 20: neg r1 21: neg 2(r3) 22: sbc r1 23: inc (r2) 24: pwril: 25: clr r0 26: div $10.,r0 27: mov r0,(r3) 28: mov r1,r0 29: asl r0 30: asl r0 31: add $pw_tab,r0 32: mov (r0)+,r1 33: mov r0,-(sp) 34: clr r0 35: add 2(r3),r1 36: adc r0 37: div $10.,r0 38: add $'0,r1 39: movb r1,-(r2) 40: add *(sp)+,r0 41: adc (r3) 42: beq 1f 43: mov r0,2(r3) 44: mov (r3),r1 45: br pwril 46: 1: 47: mov r0,r1 48: beq 1f 49: pwrsl: 50: clr r0 51: div $10.,r0 52: add $'0,r1 53: movb r1,-(r2) 54: mov r0,r1 55: bne pwrsl 56: 1: 57: mov r2,r4 58: sub sp,r2 59: sub $14.,r2 60: neg r2 61: mov -2(r3),r3 62: sub r2,r3 63: tst 14.(sp) 64: beq 1f 65: dec r3 66: 1: 67: dec r3 68: bmi 1f 69: mov $' ,r0 70: jsr pc,2f 71: br 1b 72: 1: 73: tst 14.(sp) 74: beq 1f 75: mov $'-,r0 76: jsr pc,2f 77: 1: 78: dec r2 79: bmi 1f 80: movb (r4)+,r0 81: jsr pc,2f 82: br 1b 83: 1: 84: add $14.,sp 85: jmp cret 86: 2: 87: mov r0,-(sp) / routine to call _pwrite with a char 88: clr -(sp) 89: mov $O_WRITC,-(sp) 90: jsr pc,_pwrite 91: add $6,sp 92: rts pc 93: / 94: / Table of quotients and remainders of dividing integer high 95: / words and zero low words by 10. Table was generated using dc. 96: / 97: .data 98: pw_tab: 99: 0; 0 100: 6; 14631 101: 2; 31463 102: 10; 46314 103: 4; 63146 104: 0; 100000 105: 6; 114631 106: 2; 131463 107: 10; 146314 108: 4; 163146 109: .text