Skip to content

Instantly share code, notes, and snippets.

@drdnar
Created April 16, 2020 20:58
Show Gist options
  • Save drdnar/91ae33996680acfa90d5f518b43f950e to your computer and use it in GitHub Desktop.
Save drdnar/91ae33996680acfa90d5f518b43f950e to your computer and use it in GitHub Desktop.
Cache thrash test 2
/*
*--------------------------------------
* 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 hl, 0");
asm(" exx");
asm(" ld hl, 0");
asm(" ld ix, 0");
asm(" ld iy, 0");
asm(" ld bc, $0008");
asm("loop:");
asm(" exx");
asm(" ld de, (hl)");
asm(" exx");
asm(" ld de, (hl)");
asm(" ld de, (ix)");
asm(" ld de, (iy)");
asm(" exx");
asm(" ld de, (hl)");
asm(" exx");
asm(" ld de, (hl)");
asm(" ld de, (ix)");
asm(" ld de, (iy)");
asm(" exx");
asm(" ld de, (hl)");
asm(" exx");
asm(" ld de, (hl)");
asm(" ld de, (ix)");
asm(" ld de, (iy)");
asm(" exx");
asm(" ld de, (hl)");
asm(" exx");
asm(" ld de, (hl)");
asm(" ld de, (ix)");
asm(" ld de, (iy)");
asm(" exx");
asm(" ld de, (hl)");
asm(" exx");
asm(" ld de, (hl)");
asm(" ld de, (ix)");
asm(" ld de, (iy)");
asm(" exx");
asm(" ld de, (hl)");
asm(" exx");
asm(" ld de, (hl)");
asm(" ld de, (ix)");
asm(" ld de, (iy)");
asm(" exx");
asm(" ld de, (hl)");
asm(" exx");
asm(" ld de, (hl)");
asm(" ld de, (ix)");
asm(" ld de, (iy)");
asm(" exx");
asm(" ld de, (hl)");
asm(" exx");
asm(" ld de, (hl)");
asm(" ld de, (ix)");
asm(" ld de, (iy)");
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 hl, 0");
asm(" exx");
asm(" ld hl, $10000");
asm(" ld ix, $20000");
asm(" ld iy, $30000");
asm(" ld bc, $0008");
asm("loop2:");
asm(" exx");
asm(" ld de, (hl)");
asm(" exx");
asm(" ld de, (hl)");
asm(" ld de, (ix)");
asm(" ld de, (iy)");
asm(" exx");
asm(" ld de, (hl)");
asm(" exx");
asm(" ld de, (hl)");
asm(" ld de, (ix)");
asm(" ld de, (iy)");
asm(" exx");
asm(" ld de, (hl)");
asm(" exx");
asm(" ld de, (hl)");
asm(" ld de, (ix)");
asm(" ld de, (iy)");
asm(" exx");
asm(" ld de, (hl)");
asm(" exx");
asm(" ld de, (hl)");
asm(" ld de, (ix)");
asm(" ld de, (iy)");
asm(" exx");
asm(" ld de, (hl)");
asm(" exx");
asm(" ld de, (hl)");
asm(" ld de, (ix)");
asm(" ld de, (iy)");
asm(" exx");
asm(" ld de, (hl)");
asm(" exx");
asm(" ld de, (hl)");
asm(" ld de, (ix)");
asm(" ld de, (iy)");
asm(" exx");
asm(" ld de, (hl)");
asm(" exx");
asm(" ld de, (hl)");
asm(" ld de, (ix)");
asm(" ld de, (iy)");
asm(" exx");
asm(" ld de, (hl)");
asm(" exx");
asm(" ld de, (hl)");
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