; clock.asm ; CPU clock speed test for TI-84+CSE ; Only accurate to +/- 50 kHz or so ; critor ran this and got ; 13960 33651 33669 33686 ; = 6.30 15.19 15.20 15.21 MHz ; http://tiplanet.org/forum/gallery/image.php?album_id=144&image_id=2100&view=no_count ; numOfTicks should have been changed to like 64 or 32 for support for reading ; speeds greater than 16 MHz .nolist ;=============================================================================== ;====== Include Stuff ========================================================== ;=============================================================================== ;Included for TASM Compatibility ;------------------------------- #define equ .equ #define EQU .equ #define end .end #define END .end ;Banked Call Equates/Macros ;----------------------------------------------- rBR_CALL equ 28h BRT_JUMP0 equ 50h #define bcall(xxxx) rst 28h \ .dw xxxx #define b_call(xxxx) rst 28h \ .dw xxxx #define bjump(xxxx) call 50h \ .dw xxxx ;Common Restart Routines ;------------------------------ rOP1TOOP2 equ 08h rFINDSYM equ 10h rPUSHREALO1 equ 18h rMOV9TOOP1 equ 20h rFPADD equ 30h ;Error Handler Equates/Macros ;------------------------------------------- APP_PUSH_ERRORH equ 59h APP_POP_ERRORH equ 5Ch #define AppOnErr(xxxx) ld hl,xxxx \ call 59h #define AppOffErr call 5Ch ; System routines ;----------------------------------------------- _cphlde equ 400Ch _PutC equ 44FBh _PutS equ 4501h _getKey equ 495Dh _dispHL equ 44FEh ; Memory Equates ;----------------------------------------------- appData equ 8000h ramCode equ 8100h OP1 equ 84AEh flags equ 8B26h userMem equ 0A60Bh ; EXTENDED TOKENS ;----------------------------------------------- ; These are new on OSes after 1.15 or whatever tExtTok equ 0EFh ; MathPrint tZQuadrant equ 17h tZFracHalf equ 18h tZFracThird equ 19h tZFracFourth equ 1Ah tZFracFifth equ 1Bh tZFracEighth equ 1Ch tZFracTenth equ 1Dh tFracSlash equ 2Eh tFracMixedNum equ 2Fh tSwapImProper equ 30h tSwapFracDec equ 31h tRemainder equ 32h tSummationSigma equ 33h tLogBase equ 34h tRandIntNoRep equ 35h tMathPrint equ 37h tClassic equ 38h tAutoAnswer equ 3Bh tDecAnswer equ 3Ch tFracAnswer equ 3Dh ; TI-84+CSE tBlue equ 41h tRed equ 42h tBlack equ 43h tMagenta equ 44h tGreen equ 45h tOrange equ 46h tBrown equ 47h tNavy equ 48h tLtBlue equ 49h tYellow equ 4Ah tWhite equ 4Bh tLtGray equ 4Ch tMedGray equ 4Dh tGray equ 4Eh tDarkGray equ 4Fh tGraphColor equ 65h tTextColor equ 67h tBackgroundOn equ 5Bh tBackgroundOff equ 64h tThin equ 74h ;tThick - 0x7E 0x06 (was "Connected"?) tAsm84CPrgm equ 68h tAsm84CCmp equ 69h tBorderColor equ 6Ch ;------ Hardware Ports --------------------------------------------------------- ; p = Port ; LnkAst = Link Assist ; Se = Silver Edition, Be = Basic Edition ; Cfg = Configuration, Ctrl = Control ; M = Memory, Int = Interrupt, Id = Identification ; Tmr = Timer, Rtc = Real Time Clock, Usb = USB ; Unk = Unknown pLink equ 0 pKey equ 1 pStatus equ 2 pIntMask equ 3 pIntId equ 4 pMMapTmrFreq equ 4 pMPageC equ 5 pLnkAstBeRead equ 5 pMPageA equ 6 pMPageB equ 7 pLnkAstSeEnable equ 8 pLnkAstSeStatus equ 9 pLnkAstSeInBuf equ 0Ah pLnkAstSeCfg equ 0Ah pLnkAstSeRcvTimeout equ 0Bh pLnkAstSeSndTimeout equ 0Ch pLnkAstSeOutBuf equ 0Dh pMPageAHighBits equ 0Eh pMPageBHighBits equ 0Fh pLcdCmd equ 10h pLcdData equ 11h pProtCtrl equ 14h pAsicId equ 15h pCpuSpeed equ 20h pFlashTypeRamMask equ 21h pFlashExecLowerLimit equ 22h pFlashExecUpperLimit equ 23h pFlashExecExecOverride equ 24h pRamExecLowerLimit equ 25h pRamExecUpperLimit equ 26h pBlockMRemapC equ 27h pBlockMRemapB equ 28h pLcdDelay0 equ 29h pLcdDelay1 equ 2Ah pLcdDelay2 equ 2Bh pLcdDelay3 equ 2Ch pUnknown2D equ 2Dh pMemDelay equ 2Eh pLcdGenDelay equ 2Fh pTmr1Freq equ 30h pTmr1Cfg equ 31h pTmr1Count equ 32h pTmr2Freq equ 33h pTmr2Cfg equ 34h pTmr2Count equ 35h pTmr3Freq equ 36h pTmr3Cfg equ 37h pTmr3Count equ 38h pUsbUnkOldFlg equ 39h pUsbUnkOldFlg2 equ 3Ah pRtcCtrl equ 40h pRtcSet0 equ 41h pRtcSet1 equ 42h pRtcSet2 equ 43h pRtcSet3 equ 44h pRtc0 equ 45h ; Reading pRtc1 equ 46h pRtc2 equ 47h pRtc3 equ 48h ; CPU Speeds cpu6MHz equ 0 cpu15MHz equ 1 cpu15MHz2 equ 2 cpu15MHz3 equ 3 ; Crystal Timer Equates tmrOff equ 0 tmr11000Hz equ 40h tmr1000Hz equ 41h tmr100Hz equ 42h tmr10Hz equ 43h tmr32768Hz equ 44h tmr2048Hz equ 45h tmr128Hz equ 46h tmr8Hz equ 47h tmrCpu equ 80h tmrCpuDiv2 equ 81h tmrCpuDiv4 equ 82h tmrCpuDiv8 equ 84h tmrCpuDiv16 equ 88h tmrCpuDiv32 equ 90h tmrCpuDiv64 equ 0A0h tmrNullAck equ 0 tmrLoop equ 1 tmrInt equ 2 tmrLoopAndInt equ 3 .list ;=============================================================================== ;====== Actual Program Code ==================================================== ;=============================================================================== ;====== Program Equates ======================================================== numOfTicks .equ 254; 32 ;====== Program ================================================================ .org userMem - 2 .db tExtTok, tAsm84CCmp ld hl, startMsg b_call(_PutS) ;b_call(_NewLine) xor a ; cpu6MHz out (pMemDelay), a ; Erase any memory access delays out (pCpuSpeed), a call findCPUSpeed ld a, cpu15MHz out (pCpuSpeed), a call findCPUSpeed ld a, cpu15MHz2 out (pCpuSpeed), a call findCPUSpeed ld a, cpu15MHz3 out (pCpuSpeed), a call findCPUSpeed ld hl, endMsg b_call(_PutS) ret findCPUSpeed: speedTest: ; This uses the crystal timers to time a loop which takes a known amount of CPU ; clock cycles. This is then used to calculate the CPU clock speed. If you ; make the loop longer or shorter, remember to update the section below that ; computes the speed or you might get some wild results! The loop should be as ; short as possible for better results. di ld de, $0 ; ld hl, 8000h ld ix, 8001h ld a, tmr2048Hz ; 2048 Hz out (pTmr1Freq), a xor a out (pTmr1Cfg), a ld a, numOfTicks out (pTmr1Count), a speedLoop: inc de ; 6 ; 0 ;ld (hl), 0 ; 10 ld (ix+0), 0 ; 19 in a, (pIntId) ; 11 bit 5, a ; 8 jr z, speedLoop ; 12 ; 37 cycles ; or 47 or 56 cycles ; Currently 56 xor a out (pTmr1Cfg), a out (pTmr1Freq), a ei ; Compute speed ex de, hl call DispDec ld a, 32 b_call(_PutC) ret ;====== Routines =============================================================== DispDec: ld bc,-10000 call Num1 ld bc,-1000 call Num1 ld bc,-100 call Num1 ld c,-10 call Num1 ld c,b Num1 ld a,'0'-1 Num2 inc a add hl,bc jr c,Num2 sbc hl,bc b_call(_PutC) ret ;====== Data =================================================================== ;12345678901234567890123456 startMsg: .db "Starting CPU speed test. " .db 0 endMsg: .db " " .db "Multiply each number by " .db "451.529 for speed in Hz. " .db "Also, f1r5t p0s7!!!111!one" .db 0 .end .end