1: / fp1 -- floating point simulator 2: 3: rti = 2 4: bpt = 3 5: 6: m.ext = 200 / long mode bit 7: m.lngi = 100 / long integer mode 8: 9: .globl fptrap 10: .globl ac0, ac1, ac2, ac3 11: 12: fptrap: 13: dec reenter 14: bge 1f 15: 4 / reentered! 16: 1: 17: mov (sp)+,spc 18: mov (sp)+,sps 19: mov r0,sr0 20: mov $sr1,r0 21: mov r1,(r0)+ 22: mov r2,(r0)+ 23: mov r3,(r0)+ 24: mov r4,(r0)+ 25: mov r5,(r0)+ 26: mov sp,(r0)+ 27: mov (r0),r5 / pc 28: mov -(r5),r5 / trapped instruction 29: 30: again: 31: sub $8,sp / room for double push 32: clr trapins 33: mov r5,r4 34: bic $7777,r4 35: cmp r4,$170000 36: beq 1f 37: jmp badins 38: 1: 39: bic $100000,fpsr / clear fp error 40: bic $170000,r5 41: mov r5,r4 42: bit $7000,r4 43: bne class3 44: bit $700,r4 45: bne class2 46: cmp r4,$12 47: blos 1f 48: jmp badins 49: 1: 50: asl r4 51: jmp *1f(r4) 52: 53: .data 54: 1: 55: i.cfcc / 170000 56: i.setf / 170001 57: i.seti / 170002 58: badins 59: badins 60: badins 61: badins 62: badins 63: badins 64: i.setd / 170011 65: i.setl / 170012 66: .text 67: 68: class2: 69: cmp r5,$400 70: bge 1f 71: jsr r1,fsrc; mod0rx; mod242 72: br 2f 73: 1: 74: jsr r1,fsrc; mod0f; mod24f 75: 2: 76: mov r3,r5 77: asl r4 78: asl r4 79: clrb r4 80: swab r4 81: asl r4 82: jsr pc,*1f(r4) 83: jmp sret 84: 85: .data 86: 1: 87: badins / 1700xx 88: i.ldfps / 1701xx 89: i.stfps / 1702xx 90: badins / 1703xx - stst 91: i.clrx / 1704xx 92: i.tstx / 1705xx 93: i.absx / 1706xx 94: i.negx / 1707xx 95: .text 96: 97: class3: 98: cmp r5,$5000 99: blt 1f 100: mov r5,r2 101: clrb r2 102: cmp r2,$6400 103: blt 2f 104: sub $1400,r2 105: 2: 106: cmp r2,$5000 107: bne 2f 108: jsr r1,fsrc; mod0rx; mod242 109: br 3f 110: 2: 111: cmp r2,$5400 112: bne 2f 113: jsr r1,fsrc; mod0ra; mod24i 114: br 3f 115: 2: 116: jsr r1,fsrc; mod0f; mod24d 117: br 3f 118: 1: 119: jsr r1,fsrc; mod0f; mod24f 120: 3: 121: jsr pc,freg 122: mov r2,r5 123: clrb r4 124: swab r4 125: asl r4 126: jsr pc,*1f(r4) 127: br sret 128: 129: .data 130: 1: 131: badins / 1700xx 132: badins / 1704xx 133: i.mulx / 1710xx 134: i.modx / 1714xx 135: i.addx / 1720xx 136: i.ldx / 1724xx 137: i.subx / 1730xx 138: i.cmpx / 1734xx 139: i.stx / 1740xx 140: i.divx / 1744xx 141: i.stexp / 1750xx 142: i.stcxj / 1754xx 143: i.stcxy / 1760xx 144: i.ldexp / 1764xx 145: i.ldcjx / 1770xx 146: i.ldcyx / 1774xx 147: .text 148: 149: i.cfcc: 150: mov fpsr,r0 151: bic $!17,r0 152: mov r0,sps 153: br ret 154: 155: i.setf: 156: bic $m.ext,fpsr 157: br ret 158: 159: i.setd: 160: bis $m.ext,fpsr 161: br ret 162: 163: i.seti: 164: bic $m.lngi,fpsr 165: br ret 166: 167: i.setl: 168: bis $m.lngi,fpsr 169: br ret 170: 171: badins: 172: inc trapins 173: br ret1 174: 175: sret: 176: mov $fpsr,r0 177: bic $17,(r0) 178: tstb 1(r5) 179: bpl 1f 180: bis $10,(r0) 181: br ret 182: 1: 183: bne ret 184: bis $4,(r0) 185: 186: ret: 187: mov ssp,sp 188: mov *spc,r5 189: cmp r5,$170000 190: blo ret1 191: add $2,spc 192: jbr again / if another fp, save trap 193: 194: ret1: 195: mov $sr1,r0 196: mov (r0)+,r1 197: mov (r0)+,r2 198: mov (r0)+,r3 199: mov (r0)+,r4 200: mov (r0)+,r5 201: mov (r0)+,sp 202: mov sr0,r0 203: mov sps,-(sp) 204: mov spc,-(sp) 205: tst trapins 206: bne 1f 207: inc reenter 208: rti 209: 1: 210: bpt 211: 212: freg: 213: mov r5,r2 214: bic $!300,r2 215: asr r2 216: asr r2 217: asr r2 218: add $ac0,r2 219: rts pc 220: 221: fsrc: 222: mov r5,r3 223: bic $!7,r3 / register 224: asl r3 225: add $sr0,r3 226: mov r5,r0 227: bic $!70,r0 / mode 228: asr r0 229: asr r0 230: jmp *1f(r0) 231: 232: .data 233: 1: 234: mod0 235: mod1 236: mod2 237: mod3 238: mod4 239: mod5 240: mod6 241: mod7 242: .text 243: 244: mod24f: 245: mov $4,r0 246: bit $m.ext,fpsr 247: beq 1f 248: add $4,r0 249: 1: 250: rts pc 251: 252: mod24d: 253: mov $8,r0 254: bit $m.ext,fpsr 255: beq 1f 256: sub $4,r0 257: 1: 258: rts pc 259: 260: mod242: 261: mov $2,r0 262: rts pc 263: 264: mod24i: 265: mov $2,r0 266: bit $m.lngi,fpsr 267: beq 1f 268: add $2,r0 269: 1: 270: rts pc 271: 272: mod0: 273: jmp *(r1)+ 274: 275: mod0f: 276: sub $sr0,r3 / get fp ac 277: cmp r3,$6*2 278: bhis badi1 279: asl r3 280: asl r3 281: add $ac0,r3 282: tst (r1)+ 283: rts r1 284: 285: mod0ra: 286: bit $m.lngi,fpsr 287: bne badi1 288: 289: mod0r: 290: cmp r3,$ssp 291: bhis badi1 292: mod0rx: 293: tst (r1)+ 294: rts r1 295: 296: mod1: 297: cmp r3,$spc 298: beq badi1 299: mov (r3),r3 300: br check 301: 302: mod2: 303: mov (r3),-(sp) 304: jsr pc,*2(r1) 305: cmp r3,$spc 306: bne 1f 307: mov $2,r0 308: mov *(r3),pctmp 309: mov $pctmp,(sp) 310: 1: 311: add r0,(r3) 312: mov (sp)+,r3 313: br check 314: 315: mod3: 316: mov *(r3),-(sp) 317: add $2,(r3) 318: mov (sp)+,r3 319: br check 320: 321: mod4: 322: cmp r3,$spc / test pc 323: beq badi1 324: jsr pc,*2(r1) 325: sub r0,(r3) 326: mov (r3),r3 327: br check 328: 329: mod5: 330: cmp r3,$spc 331: beq badi1 332: sub $2,(r3) 333: mov *(r3),r3 334: br check 335: 336: mod6: 337: mov *spc,-(sp) 338: add $2,spc 339: add (r3),(sp) 340: mov (sp)+,r3 341: br check 342: 343: mod7: 344: jsr r1,mod6; ..; .. 345: mov (r3),r3 346: br check 347: 348: badi1: 349: jmp badins 350: 351: check: 352: bit $1,r3 353: bne badi1 354: cmp (r1)+,(r1)+ 355: rts r1 356: 357: setab: 358: mov $asign,r0 359: jsr pc,seta 360: mov r3,r2 361: mov $bsign,r0 362: 363: seta: 364: clr (r0) 365: mov (r2)+,r1 366: mov r1,-(sp) 367: beq 1f 368: blt 2f 369: inc (r0)+ 370: br 3f 371: 2: 372: dec (r0)+ 373: 3: 374: bic $!177,r1 375: bis $200,r1 376: br 2f 377: 1: 378: clr (r0)+ 379: 2: 380: mov r1,(r0)+ 381: mov (r2)+,(r0)+ 382: bit $m.ext,fpsr 383: beq 2f 384: mov (r2)+,(r0)+ 385: mov (r2)+,(r0)+ 386: br 3f 387: 2: 388: clr (r0)+ 389: clr (r0)+ 390: 3: 391: mov (sp)+,r1 392: asl r1 393: clrb r1 394: swab r1 395: sub $200,r1 396: mov r1,(r0)+ / exp 397: rts pc 398: 399: norm: 400: mov $areg,r0 401: mov (r0)+,r1 402: mov r1,-(sp) 403: mov (r0)+,r2 404: bis r2,(sp) 405: mov (r0)+,r3 406: bis r3,(sp) 407: mov (r0)+,r4 408: bis r4,(sp)+ 409: bne 1f 410: clr asign 411: rts pc 412: 1: 413: bit $!377,r1 414: beq 1f 415: clc 416: ror r1 417: ror r2 418: ror r3 419: ror r4 420: inc (r0) 421: br 1b 422: 1: 423: bit $200,r1 424: bne 1f 425: asl r4 426: rol r3 427: rol r2 428: rol r1 429: dec (r0) 430: br 1b 431: 1: 432: mov r4,-(r0) 433: mov r3,-(r0) 434: mov r2,-(r0) 435: mov r1,-(r0) 436: rts pc