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