|
|
1.1 ! root 1: ; Check CPU cycles. Note that this test only runs in 8 MHz ST color modes! ! 2: ! 3: opt x+ ! 4: ! 5: clr.w -(sp) ! 6: pea filename ! 7: move.w #$3C,-(sp) ! 8: trap #1 ; Fcreate ! 9: addq.l #8,sp ! 10: move.w d0,fhndl ! 11: ! 12: lea tests,a4 ! 13: ! 14: main_loop: ! 15: move.l (a4)+,-(sp) ! 16: bsr print ! 17: addq.l #4,sp ! 18: ! 19: pea septext ! 20: bsr print ! 21: addq.l #4,sp ! 22: ! 23: move.l (a4)+,-(sp) ! 24: bsr run_test ! 25: addq.l #4,sp ! 26: ! 27: pea numbertext ! 28: bsr print ! 29: addq.l #4,sp ! 30: ! 31: tst.l (a4) ! 32: bne.s main_loop ! 33: ! 34: move.w fhndl,-(sp) ! 35: move.w #$3E,-(sp) ! 36: trap #1 ; Fclose ! 37: addq.l #4,sp ! 38: ! 39: ; move.w #7,-(sp) ! 40: ; trap #1 ; Crawcin ! 41: ; addq.l #2,sp ! 42: ! 43: clr.w -(sp) ! 44: trap #1 ! 45: ! 46: print: ! 47: move.l 4(sp),-(sp) ! 48: move.w #9,-(sp) ! 49: trap #1 ; Cconws ! 50: addq.l #6,sp ! 51: ! 52: moveq #-1,d0 ! 53: move.l 4(sp),a0 ! 54: strlenloop: ! 55: addq.l #1,d0 ! 56: tst.b (a0)+ ! 57: bne.s strlenloop ! 58: ! 59: move.l 4(sp),-(sp) ! 60: move.l d0,-(sp) ! 61: move.w fhndl,-(sp) ! 62: move.w #$40,-(sp) ! 63: trap #1 ; Fwrite ! 64: lea 12(sp),sp ! 65: out: ! 66: rts ! 67: ! 68: ; *************** The tests ****************** ! 69: ! 70: text_nop: ! 71: dc.b "one nop",0 ! 72: even ! 73: test_nop: ! 74: nop ; 4 cycles ! 75: rts ! 76: ! 77: text_2nop: ! 78: dc.b "two nops",0 ! 79: even ! 80: test_2nop: ! 81: nop ; 4 cycles ! 82: nop ; 4 cycles ! 83: rts ! 84: ! 85: text_lsl1: ! 86: dc.b "lsl #0",0 ! 87: even ! 88: test_lsl1: ! 89: moveq #0,d0 ; 4 cycles ! 90: lsl.l d0,d1 ; 8 + 2 * 0 = 8 cycles ! 91: rts ! 92: ! 93: text_lsl2: ! 94: dc.b "lsl #6",0 ! 95: even ! 96: test_lsl2: ! 97: moveq #6,d0 ; 4 cycles ! 98: lsl.l d0,d1 ; 8 + 2 * 6 = 20 cycles ! 99: rts ! 100: ! 101: text_exg_dbra1: ! 102: dc.b "nop+exg+dbra",0 ! 103: even ! 104: test_exg_dbra1: ! 105: moveq #0,d2 ; 4 cycles ! 106: nop ; 4 cycles ! 107: exg d0,d1 ; 6 cycles (pairing with the following instruction!) ! 108: dbra d2,out ; 14 cycles ! 109: rts ! 110: ! 111: text_exg_dbra2: ! 112: dc.b "exg+nop+dbra",0 ! 113: even ! 114: test_exg_dbra2: ! 115: moveq #0,d2 ; 4 cycles ! 116: exg d0,d1 ; 6 cycles, rounded to 8 (no pairing!) ! 117: nop ; 4 cycles ! 118: dbra d2,out ; 14 cycles, rounded to 16 ! 119: rts ! 120: ! 121: text_exg_move1: ! 122: dc.b "nop+exg+move",0 ! 123: even ! 124: test_exg_move1: ! 125: nop ; 4 cycles ! 126: exg d0,d1 ; 6 cycles (pairing with the following instruction!) ! 127: move.b -(a0),d1 ; 10 cycles ! 128: rts ! 129: ! 130: text_exg_move2: ! 131: dc.b "exg+nop+move",0 ! 132: even ! 133: test_exg_move2: ! 134: exg d0,d1 ; 6 cycles, will be rounded to 8 cycles (no pairing) ! 135: nop ; 4 cycles ! 136: move.b -(a0),d1 ; 10 cycles, will be rounded to 12 ! 137: rts ! 138: ! 139: text_asr_add1: ! 140: dc.b "nop+asr+add",0 ! 141: even ! 142: test_asr_add1: ! 143: moveq #2,d0 ; 4 cycles ! 144: nop ; 4 cycles ! 145: asr.w d0,d1 ; 6 + 2 * 2 = 10 cycles (not 12, thanks to pairing!) ! 146: add.w -(a0),d1 ; 10 cycles ! 147: rts ! 148: ! 149: text_asr_add2: ! 150: dc.b "asr+nop+add",0 ! 151: even ! 152: test_asr_add2: ! 153: moveq #2,d0 ; 4 cycles ! 154: asr.w d0,d1 ; 6 + 2 * 2 = 10 cycles, rounded to 12 ! 155: nop ; 4 cycles ! 156: add.w -(a0),d1 ; 10 cycles, rounded to 12 ! 157: rts ! 158: ! 159: text_cmp_beq1: ! 160: dc.b "nop+cmp+beq",0 ! 161: even ! 162: test_cmp_beq1: ! 163: nop ; 4 cycles ! 164: cmp.l d0,d0 ; 6 cycles ! 165: bra out ; 10 cycles ! 166: ! 167: text_cmp_beq2: ! 168: dc.b "cmp+nop+beq",0 ! 169: even ! 170: test_cmp_beq2: ! 171: cmp.l d0,d0 ; 6 cycles, rounded to 8 ! 172: nop ; 4 cycles ! 173: bra out ; 10 cycles, rounded to 12 ! 174: ! 175: text_sub_move1: ! 176: dc.b "clr+sub+move",0 ! 177: even ! 178: test_sub_move1: ! 179: clr.w d2 ; 4 cycles ! 180: sub.l (a0),d0 ; 10 cycles ! 181: move.w 0(a0,d2),d1 ; 14 cycles ! 182: rts ! 183: ! 184: text_sub_move2: ! 185: dc.b "sub+clr+move",0 ! 186: even ! 187: test_sub_move2: ! 188: sub.l (a0),d0 ; 10 cycles, rounded to 12 ! 189: clr.w d2 ; 4 cycles ! 190: move.w 0(a0,d2),d1 ; 14 cycles, rounded to 16 ! 191: rts ! 192: ! 193: text_move_820a: ! 194: dc.b "move ff820a",0 ! 195: even ! 196: test_move_820a: ! 197: move.b $ffff820a.w,d0 ; 12 cycles ! 198: rts ! 199: ! 200: text_move_8800: ! 201: dc.b "move ff8800",0 ! 202: even ! 203: test_move_8800: ! 204: move.b $ffff8800.w,d0 ; 12 cycles + wait state = 16 cycles ! 205: rts ! 206: ! 207: tests: ! 208: dc.l text_nop, test_nop ! 209: dc.l text_2nop, test_2nop ! 210: dc.l text_lsl1, test_lsl1 ! 211: dc.l text_lsl2, test_lsl2 ! 212: dc.l text_exg_dbra1, test_exg_dbra1 ! 213: dc.l text_exg_dbra2, test_exg_dbra2 ! 214: dc.l text_exg_move1, test_exg_move1 ! 215: dc.l text_exg_move2, test_exg_move2 ! 216: dc.l text_asr_add1, test_asr_add1 ! 217: dc.l text_asr_add2, test_asr_add2 ! 218: dc.l text_cmp_beq1, test_cmp_beq1 ! 219: dc.l text_cmp_beq2, test_cmp_beq2 ! 220: dc.l text_sub_move1, test_sub_move1 ! 221: dc.l text_sub_move2, test_sub_move2 ! 222: dc.l text_move_820a, test_move_820a ! 223: dc.l text_move_8800, test_move_8800 ! 224: dc.l 0, 0 ! 225: ! 226: ! 227: ********************************************** ! 228: * Mini-program to determine the number of * ! 229: * clockcycles a routine uses * ! 230: * by Niclas Thisell * ! 231: ********************************************** ! 232: ! 233: testinit: ! 234: move.l #scratch,a0 ! 235: rts ! 236: ! 237: ; Put routine to test on stack before calling this function ! 238: run_test: ! 239: move.l 4(sp),d0 ! 240: movem.l d3-d7/a3-a6,-(sp) ! 241: move.l d0,a5 ; ; pointer to test routine in a5 ! 242: ! 243: pea 0 ! 244: move.w #$0020,-(sp) ! 245: trap #1 ! 246: addq.l #6,sp ! 247: move.l d0,old_ssp ! 248: ! 249: move.l $00000010,saveillegal ! 250: move.w #$0765,$ffff8240.w ! 251: move.b #2,$ffff820a.w ! 252: ! 253: loop: ! 254: move.l $70,old_vbl ! 255: move.l #vblhandler,$70 ! 256: move.w #0,got_vbl ! 257: stop #$2300 ; Wait for VBL ! 258: tst.w got_vbl ! 259: beq.s loop ! 260: move.l old_vbl,$70 ! 261: ! 262: move #$2700,sr ! 263: jsr testinit ! 264: move.l a0,-(sp) ! 265: move.w d0,-(sp) ! 266: lea $ffff8209.w,a0 ! 267: moveq #0,d0 ! 268: .wait: ! 269: move.b (a0),d0 ! 270: beq.s .wait ! 271: not.w d0 ! 272: lsr.w d0,d0 ! 273: move.w #128,d0 ! 274: sub.w nopno(pc),d0 ! 275: add.w d0,d0 ! 276: jmp .jmpbase(pc,d0.w) ! 277: .jmpbase: ! 278: REPT 128 ! 279: nop ! 280: ENDR ! 281: ! 282: move.w (sp)+,d0 ! 283: movea.l (sp)+,a0 ! 284: ;************************************ ! 285: ;sprite-routine or whatever here! ! 286: jsr (a5) ! 287: continue: ! 288: ;*********************************** ! 289: move.b $ffff8209.w,d0 ! 290: move.b $ffff8207.w,d1 ! 291: move.b $ffff8205.w,d2 ! 292: move.b $ffff8209.w,d3 ! 293: sub.b d0,d3 ! 294: cmp.b #18,d3 ! 295: beq.s .found_values ! 296: addq.w #5,nopno ! 297: andi.w #127,nopno ! 298: beq something_wrong_here ! 299: move.w #$0765,$ffff8240.w ! 300: move #$2300,sr ! 301: bra loop ! 302: .found_values: ! 303: move.w #$0770,$ffff8240.w ! 304: move #$2300,sr ! 305: ! 306: and.l #$000000ff,d0 ! 307: and.l #$000000ff,d1 ! 308: and.l #$000000ff,d2 ! 309: lsl.w #8,d2 ! 310: add.w d1,d2 ! 311: lsl.l #8,d2 ! 312: add.w d0,d2 ! 313: sub.l $0000044e,d2 ! 314: divu #160,d2 ! 315: move.l d2,d0 ! 316: mulu #256,d0 ! 317: swap d2 ! 318: add.w d2,d0 ! 319: sub.w nopno(pc),d0 ! 320: sub.w nopno(pc),d0 ! 321: add.w d0,d0 ! 322: sub.w #248,d0 ! 323: bra getouttahere ! 324: something_wrong_here: ! 325: move.w #10000,d0 ! 326: .p: addi.w #$0123,$ffff8240.w ! 327: dbra d0,.p ! 328: moveq #0,d0 ! 329: bra getouttahere ! 330: nopno: dc.w 0 ! 331: ! 332: getouttahere: ! 333: move #$2300,sr ! 334: move.b #2,$ffff820a.w ! 335: move.w #$0777,$ffff8240.w ! 336: ! 337: lea numbertext+5(pc),a0 ! 338: moveq #4,d7 ! 339: .decoutloop: ! 340: divu #10,d0 ! 341: swap d0 ! 342: add.w #"0",d0 ! 343: move.b d0,-(a0) ! 344: clr.w d0 ! 345: swap d0 ! 346: dbra d7,.decoutloop ! 347: ! 348: move.l saveillegal,$00000010 ! 349: ! 350: move.l old_ssp,-(sp) ! 351: move.w #$20,-(sp) ! 352: trap #1 ; Super ! 353: addq.l #6,sp ! 354: ! 355: movem.l (sp)+,d3-d7/a3-a6 ! 356: ! 357: rts ! 358: ! 359: vblhandler: ! 360: move.w #1,got_vbl ! 361: rte ! 362: ! 363: data ! 364: ! 365: filename: dc.b "RESULTS.TXT",0 ! 366: ! 367: septext: dc.b " :",9,0 ! 368: numbertext: dc.b " cycles",13,10,0 ! 369: even ! 370: ! 371: bss ! 372: old_ssp: ds.l 1 ! 373: saveillegal: ds.l 1 ! 374: old_vbl: ds.l 1 ! 375: got_vbl: ds.w 1 ! 376: fhndl: ds.w 1 ! 377: ! 378: ds.l 16 ! 379: scratch: ! 380: ds.l 16 ! 381: ! 382: end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.