Last active
April 16, 2020 20:58
-
-
Save drdnar/0765c3b75e05256e8c70c123c6063262 to your computer and use it in GitHub Desktop.
Cache thrash test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
*-------------------------------------- | |
* Program Name: | |
* Author: | |
* License: | |
* Description: | |
*-------------------------------------- | |
*/ | |
/* Keep these headers */ | |
#include <stdbool.h> | |
#include <stddef.h> | |
#include <stdint.h> | |
#include <tice.h> | |
/* Standard headers (recommended) */ | |
#include <math.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
/* Put your function prototypes here */ | |
/* Put all your globals here */ | |
#define COPY_SIZE 65536 | |
unsigned char target[COPY_SIZE]; | |
#define asm_var_1 (*(volatile unsigned char**)0xD00000) | |
#define asm_var_1a (*(volatile unsigned char*)0xD00000) | |
#define asm_var_2 (*(volatile unsigned int*)0xD00003) | |
void PutC(unsigned char c) | |
{ | |
asm(" di"); | |
asm_var_1a = c; | |
asm(" ld a, ($D00000)"); | |
asm(" call 00207B8h"); | |
asm(" ei"); | |
} | |
void PrintHex(uint32_t n) | |
{ | |
unsigned char i; | |
unsigned char d; | |
for (i = 0; i < 8; i++) | |
{ | |
d = (unsigned char)(n >> 28) + '0'; | |
if (d > '9') | |
d += 'A' - '9' - 1; | |
PutC(d); | |
n = n << 4; | |
} | |
} | |
void main(void) { | |
uint32_t count1; | |
uint32_t count2; | |
os_ClrHome(); | |
asm(" di"); | |
asm(" push iy"); | |
timer_Control = TIMER1_DISABLE; | |
timer_1_Counter = 0; | |
timer_Control = TIMER1_ENABLE | TIMER1_CPU | TIMER1_UP; | |
asm(" push ix"); | |
asm(" ld ix, 0"); | |
asm(" ld bc, $0008"); | |
asm("loop:"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (ix)"); | |
asm(" djnz loop"); | |
asm(" dec c"); | |
asm(" jr nz, loop"); | |
asm(" pop ix"); | |
count1 = atomic_load_increasing_32(&timer_1_Counter); | |
timer_Control = TIMER1_DISABLE; | |
timer_1_Counter = 0; | |
timer_Control = TIMER1_ENABLE | TIMER1_CPU | TIMER1_UP; | |
asm(" push ix"); | |
asm(" ld ix, 0"); | |
asm(" ld iy, 65536"); | |
asm(" ld bc, $0008"); | |
asm("loop2:"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (iy)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (iy)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (iy)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (iy)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (iy)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (iy)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (iy)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (iy)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (iy)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (iy)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (iy)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (iy)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (iy)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (iy)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (iy)"); | |
asm(" ld de, (ix)"); | |
asm(" ld de, (iy)"); | |
asm(" djnz loop2"); | |
asm(" dec c"); | |
asm(" jr nz, loop2"); | |
asm(" pop ix"); | |
count2 = atomic_load_increasing_32(&timer_1_Counter); | |
timer_Control = TIMER1_DISABLE; | |
asm(" pop iy"); | |
asm(" ei"); | |
PrintHex(count1); | |
os_NewLine(); | |
PrintHex(count2); | |
os_NewLine(); | |
/* Wait for a key press */ | |
while (!os_GetCSC()); | |
} | |
/* Put other functions here */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment