1: / 2: / BUILT IN FUNCTIONS 3: / 4: _LLIMIT: 5: add $4.,sp 6: return 7: _ARGC: 8: mov _argc,-(sp) 9: sxt -(sp) 10: return 11: _ARGV: 12: bne 1f 13: mov (lc)+,r3 14: 1: 15: mov (sp)+,r1 16: mov (sp)+,r0 17: blt 9f 18: cmp r0,_argc 19: bge 9f 20: add r0,r0 21: add _argv,r0 22: mov (r0),r0 23: inc r3 24: br 3f 25: 1: 26: movb (r0)+,r2 27: bne 2f 28: dec r0 29: mov $' ,r2 30: 2: 31: movb r2,(r1)+ 32: 3: 33: sob r3,1b 34: return 35: 9: 36: mov $EARGV,_perrno 37: error EARGV 38: _SCLCK: 39: mov $4,-(sp) 40: br 1f 41: _CLCK: 42: clr -(sp) 43: 1: 44: seti 45: sub $16.,sp 46: mov sp,r0 47: mov r0,-(sp) 48: jsr pc,_times 49: tst (sp)+ 50: mov sp,r0 51: add 16.(sp),r0 52: movif $HZ,fr1 53: setl 54: movif (r0),fr0 55: add $18.,sp 56: divf fr1,fr0 57: mulf $042572,fr0 / mulf $1000.,fr0 58: movfi fr0,-(sp) 59: return 60: _DATE: 61: _TIME: 62: asr r0 63: bic $!377,r0 64: mov r0,-(sp) 65: jsr pc,_pdattim 66: cmp (sp)+,(sp)+ 67: return 68: _SEED: 69: mov (sp)+,r0 70: mov (sp)+,r1 71: mov _seed+2,-(sp) 72: mov _seed,-(sp) 73: mov r0,_seed 74: mov r1,_seed+2 75: return 76: _RANDOM: 77: movif _seed,fr0 78: mulf _randa,fr0 79: addf _randc,fr0 80: movf fr0,fr2 81: modf _randim,fr2 82: movf fr2,(sp) 83: mulf _randm,fr2 84: movfi fr2,_seed 85: return 86: _DISPOSE: 87: tst (sp) 88: beq 1f 89: jsr pc,_free 90: 1: 91: tst (sp)+ 92: return 93: _NEW: 94: bne 1f 95: mov (lc)+,r3 96: 1: 97: mov r3,-(sp) 98: jsr pc,_alloc 99: tst (sp)+ 100: mov r0,*(sp)+ 101: return 102: _EXPO: 103: movf (sp)+,fr0 104: movei fr0,-(sp) 105: sxt -(sp) 106: return 107: _ATAN: 108: seti 109: jsr pc,_atan 110: setl 111: movf fr0,(sp) 112: return 113: _COS: 114: seti 115: jsr pc,_cos 116: setl 117: movf fr0,(sp) 118: return 119: _EXP: 120: seti 121: jsr pc,_exp 122: setl 123: movf fr0,(sp) 124: return 125: _LN: 126: tstf (sp) 127: cfcc 128: ble 9f 129: seti 130: jsr pc,_log 131: setl 132: movf fr0,(sp) 133: return 134: 9: 135: mov $ELN,_perrno 136: error ELN 137: _SIN: 138: seti 139: jsr pc,_sin 140: setl 141: movf fr0,(sp) 142: return 143: _SQRT: 144: movf (sp),fr0 145: cfcc 146: bmi 9f 147: seti 148: jsr pc,_sqrt 149: setl 150: movf fr0,(sp) 151: return 152: 9: 153: mov $ESQRT,_perrno 154: error ESQRT 155: _CHR4: 156: tst (sp)+ 157: bne 1f 158: _CHR2: 159: cmp (sp),$177 160: bhi 1f 161: return 162: 1: 163: mov $ECHR,_perrno 164: error ECHR 165: _ODD4: 166: tst (sp)+ 167: _ODD2: 168: bic $!1,(sp) 169: return 170: _PRED2: 171: dec (sp) 172: return 173: _PRED4: 174: sub $1,2(sp) 175: sbc (sp) 176: return 177: _PRED24: 178: sub $1,(sp) 179: sxt -(sp) 180: return 181: _STLIM: 182: mov (sp)+,r0 183: bge 1f 184: tst (sp)+ 185: return 186: 1: 187: mov (sp)+,r1 188: sub _stcnt+2,r1 189: sbc r0 190: sub _stcnt,r0 191: ashc $0,r0 192: bge 1f 193: mov $ESTLIM,_perrno 194: error ESTLIM 195: 1: 196: mov r0,_stlim 197: mov r1,_stlim+2 198: return 199: _SUCC2: 200: inc (sp) 201: return 202: _SUCC4: 203: add $1,2(sp) 204: adc (sp) 205: return 206: _SUCC24: 207: add $1,(sp) 208: sxt -(sp) 209: return 210: _ROUND: 211: movf (sp)+,fr0 212: cfcc 213: bmi 1f 214: addf $HALF,fr0 215: br 2f 216: 1: 217: subf $HALF,fr0 218: 2: 219: movfi fr0,-(sp) 220: return 221: _TRUNC: 222: movf (sp)+,fr0 223: movfi fr0,-(sp) 224: return 225: _UNDEF: 226: add $8,sp 227: clr -(sp) 228: return 229: / 230: / pack(a,i,z) 231: / 232: / with: a: array[m..n] of t 233: / z: packed array[u..v] of t 234: / 235: / semantics: for j := u to v do 236: / z[j] := a[j-u+i]; 237: / 238: / need to check: 239: / 1. i >= m 240: / 2. i+(v-u) <= n (i.e. i-m <= (n-m)-(v-u)) 241: / 242: / on stack: lv(z), lv(a), rv(i) (len 2) 243: / 244: / move w(t)*(v-u+1) bytes from lv(a)+w(t)*(i-m) to lv(z) 245: / 246: _PACK: 247: bne 1f 248: mov (lc)+,r3 249: 1: 250: mov $pack,reta 251: / 252: / check conditions 1 and 2 253: / 254: pakunp: 255: mov 4(sp),r1 256: sub (lc)+,r1 / m 257: blt 9f 258: cmp r1,(lc)+ / (n-m)-(u-v) 259: bgt 9f 260: mul r3,r1 261: mov (sp)+,r0 262: add (sp)+,r1 263: tst (sp)+ 264: mov (lc)+,r3 265: inc r3 266: jmp *reta 267: unpack: 268: mov r0,r2 269: mov r1,r0 270: mov r2,r1 271: br pack 272: 1: 273: movb (r1)+,(r0)+ 274: pack: 275: sob r3,1b 276: return 277: / 278: / unpack(z,a,i) 279: / 280: / with: z and a as in pack 281: / 282: / semantics: for j := u to v do 283: / a[j-u+i] := z[j] 284: / 285: _UNPACK: 286: bne 1f 287: mov (lc)+,r3 288: 1: 289: mov $unpack,reta 290: br pakunp 291: 9: 292: cmp reta,$pack 293: beq 1f 294: mov $EUNPACK,_perrno 295: error EUNPACK 296: 1: 297: mov $EPACK,_perrno 298: error EPACK 299: _WCLCK: 300: clr -(sp) 301: jsr pc,_time 302: tst (sp)+ 303: mov r1,-(sp) 304: mov r0,-(sp) 305: return