1: / fortran to UNIX IO 2: / 3: .globl read. 4: .globl write. 5: .globl seek. 6: .globl seek0. 7: .globl open. 8: .globl creat. 9: .globl close. 10: .globl errno. 11: 12: indir = 0 13: 14: / integer function read(f, a, n) 15: / integer f, n 16: / logical*1 a(n) 17: / same as C 18: 19: read.: 20: temp 21: rval4p; 2 / f 22: i4i2 23: lvalp; 4 / a 24: rval4p; 6 / n 25: i4i2 26: .+2 27: mov (sp)+,9f+4 28: mov (sp)+,9f+2 29: mov (sp)+,r0 30: sys indir; 9f 31: br ret 32: 33: .data 34: 9: sys read; ..; .. 35: .text 36: 37: / integer function read(f, a, n) 38: / integer f, n 39: / logical*1 a(n) 40: / same as C 41: 42: write.: 43: temp 44: rval4p; 2 / f 45: i4i2 46: lvalp; 4 / a 47: rval4p; 6 / n 48: i4i2 49: .+2 50: mov (sp)+,9f+4 51: mov (sp)+,9f+2 52: mov (sp)+,r0 53: sys indir; 9f 54: br ret 55: 56: .data 57: 9: sys write; ..; .. 58: .text 59: 60: / integer function seek(f, o, b) 61: / integer f, o, b 62: / same as C 63: 64: seek.: 65: temp 66: rval4p; 2 / f 67: i4i2 68: rval4p; 4 / o 69: i4i2 70: rval4p; 6 / b 71: i4i2 72: .+2 73: mov (sp)+,9f+4 74: mov (sp)+,9f+2 75: mov (sp)+,r0 76: sys indir; 9f 77: br ret 78: 79: / integer function seek0(f, n) 80: / integer f, n 81: / same as seek(f, n, 0) 82: / but with 24 bit `n' 83: 84: seek0.: 85: temp 86: rval4p; 2 / f 87: i4i2 88: rval4p; 4 / n 89: .+2 90: mov (sp)+,r0 91: mov (sp),r1 92: bic $!777,(sp) 93: ashc $-9.,r0 94: mov r1,9f+2 95: mov $3,9f+4 96: mov 2(sp),r0 97: sys indir; 9f / to block 98: mov (sp)+,9f+2 99: mov $1,9f+4 100: mov (sp)+,r0 101: sys indir; 9f / to byte within block 102: br ret 103: 104: .data 105: 9: sys seek; ..; .. 106: .text 107: 108: / integer function open(a, m) 109: / logical*1 a(n) 110: / integer m 111: / same as C, name is ` ' terminated 112: 113: open.: 114: temp 115: lvalp; 2 / a 116: rval4p; 4 / m 117: i4i2 118: .+2 119: mov (sp)+,9f+4 120: mov (sp)+,r0 121: mov r0,9f+2 122: 1: 123: cmpb (r0)+,$' / 124: bne 1b 125: clrb -(r0) 126: sys indir; 9f 127: br ret 128: 129: .data 130: 9: sys open; ..; .. 131: .text 132: 133: / integer function creat(a, m) 134: / logical*1 a(n) 135: / integer m 136: / same as C, name is ` ' terminated 137: 138: creat.: 139: temp 140: lvalp; 2 / a 141: rval4p; 4 / m 142: i4i2 143: .+2 144: mov (sp)+,9f+4 145: mov (sp)+,r0 146: mov r0,9f+2 147: 1: 148: cmpb (r0)+,$' / 149: bne 1b 150: clrb -(r0) 151: sys indir; 9f 152: br ret 153: 154: .data 155: 9: sys creat; ..; .. 156: .text 157: 158: / integer function close(f) 159: / integer f 160: / same as C 161: 162: close.: 163: temp 164: rval4p; 2 / f 165: i4i2 166: .+2 167: mov (sp)+,r0 168: sys close 169: 170: ret: 171: bec 1f 172: mov r0,error 173: mov $-1,r0 174: 1: 175: mov r0,temp+2 176: sxt temp 177: jmp retrn 178: 179: / error = errno 180: / returns last error number 181: 182: errno.: 183: temp 184: .+2 185: mov error,r0 186: br ret 187: 188: .globl temp 189: .globl retrn 190: .globl rval4p 191: .globl lvalp 192: .globl i4i2 193: .bss 194: error: .=.+2