int main(void) { static uint32_t testcase[] = { 0x80000000, 0x00000001, 0x12345678, 0x0000FFFF, 0x0F0F0F0F, 0x08080808 } ; InitializeHardware(HEADER, PROJECT_NAME) ; for (;;) { int k ; for (k = 0; k < ENTRIES(testcase); k++) { uint32_t word = testcase[k] ; uint32_t result, answer = RBIT(word) ; uint32_t before, after, cycles ; before = GetClockCycleCount() ; result = ReverseBitOrder(word) ; after = GetClockCycleCount() ; cycles = after - before ; printf(" Test Case %d: %08X (hex)\n", k+1, (unsigned) word) ; printf("Correct Result: %08X\n", (unsigned) answer) ; printf(" Your Result: %08X", (unsigned) result) ; if (result != answer) printf(" %s", ERROR_FLAG) ; printf("\n") ; printf(" Clock Cycles: %lu\n\n", cycles) ; WaitForPushButton() ; } printf("Press button to start over.\n") ; WaitForPushButton() ; ClearDisplay() ; } }
#include "../port/lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "io.h" #include "../port/error.h" #include "msaturn.h" enum { Timer_ctrl = Saturn + 0x0106, Timer0_load = Saturn + 0x0200, Timer0_cnt = Saturn + 0x0204, Timer1_load = Saturn + 0x0300, Timer1_cnt = Saturn + 0x0304, T0_event = RBIT(13, ushort), T0_ie = RBIT(14, ushort), T0_cen = RBIT(15, ushort), T1_event = RBIT(5, ushort), T1_ie = RBIT(6, ushort), T1_cen = RBIT(7, ushort), }; static ulong ticks; static Lock tlock; static ushort timer_ctl; ulong multiplier; ulong µs(void)
Ercr = Saturn + 0x0c04, Ersr = Saturn + 0x0c06, Eisr = Saturn + 0x0d04, Eimr = Saturn + 0x0d06, Emacaddr0 = Saturn + 0x0e02, Miicr = Saturn + 0x0f02, Miiwdr = Saturn + 0x0f04, Miirdr = Saturn + 0x0f06, Ethermem = 0xf2c00000, Etherfsize = 0x2000, Nrx = 14, Ntx = 2, // Nrx + Ntx must be 16 Ersr_rxfpmask = 0xf, Ersr_rxevent = RBIT(0, ushort), Etcr_txfpmask = 0xf, Ercr_rxenab = RBIT(0, ushort), Ercr_auienab = RBIT(2, ushort), Etcr_txstart = RBIT(1, ushort), Etcr_retries = 0xf<<8, Ei_txecall = RBIT(0, ushort), Ei_txretry = RBIT(2, ushort), Ei_txdefer = RBIT(3, ushort), Ei_txcrs = RBIT(4, ushort), Ei_txdone = RBIT(5, ushort), Ei_rxcrcerr = RBIT(8, ushort), Ei_rxdrib = RBIT(9, ushort), Ei_rxdone = RBIT(10, ushort), Ei_rxshort = RBIT(11, ushort), Ei_rxlong = RBIT(12, ushort),