#define CALCULATOR TI89 #include "ti89.inc" .org userMem-2 .db t2ByteTok,tAsmCmp start: ; Save registers we'll use move.l a5,-(sp) move.l a6,-(sp) ; Clear screen move.w #ClrScr,-(sp) trap #1 addq.l #2,sp ; Get initial timer value move.l #$600000,a5 ; Timer control register address move.l (a5),d0 ; Read initial value ; Perform timing loop move.l #1000000,d7 ; Number of iterations timing_loop: nop ; Single cycle operation dbf d7,timing_loop ; Get final timer value move.l (a5),d1 ; Read final value ; Calculate elapsed cycles sub.l d0,d1 ; d1 now contains elapsed timer ticks ; Calculate MHz (timer runs at 32768Hz) move.l #32768,d2 ; Timer frequency divu.w d2,d1 ; Convert to seconds ; Display result pea result_str move.w #PutS,-(sp) trap #1 addq.l #6,sp ; Restore registers and exit move.l (sp)+,a6 move.l (sp)+,a5 rts result_str: .ascii "CPU Speed (approx): " .db 0 .end start