1: / etc.s -- common code 2: 3: .globl _signal 4: mov $done,-(sp) 5: mov $2,-(sp) 6: jsr pc,_signal 7: cmp (sp)+,(sp)+ 8: jmp around 9: 10: done: 11: .globl _exit 12: jsr pc,nline 13: jsr pc,_exit 14: 15: mesg: 16: movb (r5)+,r0 17: beq 1f 18: jsr pc,putc 19: br mesg 20: 1: 21: inc r5 22: bic $1,r5 23: rts r5 24: 25: quest: 26: jsr pc,getc 27: cmp r0,$'y 28: bne 1f 29: tst (r5)+ 30: 1: 31: cmp r0,$'\n 32: beq 1f 33: jsr pc,flush 34: 1: 35: rts r5 36: 37: getc: 38: .globl _read 39: mov $1,-(sp) 40: mov $ch,-(sp) 41: clr -(sp) 42: jsr pc,_read 43: add $6,sp 44: bes done 45: tst r0 46: beq done 47: mov ch,r0 48: rts pc 49: 50: 0: 0 51: print: 52: .globl _open 53: mov r5,0b 54: mov $0b,-(sp) 55: mov $0,-(sp) 56: jsr pc,_open; 57: cmp (sp)+,(sp)+ 58: bes 1f 59: mov r0,r1 60: 2: 61: .globl _read 62: mov $1,-(sp) 63: mov $ch,-(sp) 64: mov r1,-(sp) 65: jsr pc,_read 66: add $6,sp 67: tst r0 68: beq 2f 69: mov ch,r0 70: jsr pc,putc 71: br 2b 72: 2: 73: .globl _close 74: mov r1,-(sp) 75: jsr pc,_close 76: tst (sp)+ 77: 1: 78: tstb (r5)+ 79: bne 1b 80: inc r5 81: bic $1,r5 82: rts r5 83: 84: nline: 85: mov $'\n,r0 86: 87: putc: 88: .globl _write 89: mov r0,ch 90: mov $1,-(sp) 91: mov $ch,-(sp) 92: mov $1,-(sp) 93: jsr pc,_write 94: add $6,sp 95: rts pc 96: 97: decml: 98: mov r1,-(sp) 99: jsr pc,1f 100: mov (sp)+,r1 101: rts pc 102: 103: 1: 104: mov r0,r1 105: clr r0 106: div $10.,r0 107: mov r1,-(sp) 108: tst r0 109: beq 1f 110: jsr pc,1b 111: 1: 112: mov (sp)+,r0 113: add $'0,r0 114: jsr pc,putc 115: rts pc 116: 117: flush: 118: jsr pc,getc 119: cmp r0,$'\n 120: bne flush 121: rts pc 122: 123: rand: 124: .globl _time 125: mov r1,-(sp) 126: tst randx 127: bne 1f 128: clr -(sp) 129: jsr pc,_time 130: tst (sp)+ 131: mov r1,randx 132: bis $1,randx 133: 1: 134: mov randx,r0 135: mul $15625.,r0 136: mov r1,randx 137: ashc $-2,r0 138: clr r0 139: div (r5)+,r0 140: mov r1,r0 141: mov (sp)+,r1 142: rts r5 143: 144: ch: 0 145: randx: 0 146: around: