mirror of
https://github.com/satoshinm/pill_6502.git
synced 2025-02-10 18:30:55 +00:00
Merge branch 'speed', measure hz for #1
This commit is contained in:
commit
04e78a4b0b
@ -24,7 +24,7 @@ Special commands built-in, not passed to the ACIA and 6502:
|
||||
| ^P | Pause/resume 6502 processor execution |
|
||||
| ^R | Reset the 6502 processor (also reset on USB reset) |
|
||||
| ^E | Local echo toggle, off by default |
|
||||
| ^T | Show clock ticks and instruction count |
|
||||
| ^T | Show clock ticks, instruction count, and frequency since last ^T |
|
||||
| ^G | Show help |
|
||||
|
||||
Intended to be somewhat compatible with [Grant Searle's Simple6502](http://searle.hostei.com/grant/6502/Simple6502.html),
|
||||
|
@ -3,7 +3,7 @@ MAKEFLAGS += --no-print-dir
|
||||
Q := @
|
||||
endif
|
||||
|
||||
OPT_FLAGS ?= -O2
|
||||
OPT_FLAGS = -O0 -g
|
||||
|
||||
CFLAGS += -Wall -Wextra -Werror -Wno-char-subscripts\
|
||||
$(OPT_FLAGS) -std=gnu99 -g3 -MD \
|
||||
@ -22,7 +22,6 @@ CROSS_COMPILE ?= arm-none-eabi-
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
|
||||
OPT_FLAGS = -Os
|
||||
CFLAGS += -mcpu=cortex-m3 -mthumb \
|
||||
-DSTM32F1 -DDISCOVERY_STLINK -I../libopencm3/include \
|
||||
-I .
|
||||
|
20
src/main.c
20
src/main.c
@ -84,9 +84,11 @@ static const char *usb_strings[] = {
|
||||
};
|
||||
|
||||
static bool paused = true;
|
||||
uint32_t millis = 0;
|
||||
void sys_tick_handler(void)
|
||||
{
|
||||
if (paused) return;
|
||||
++millis;
|
||||
step6502();
|
||||
gpio_toggle(GPIOC, GPIO13);
|
||||
}
|
||||
@ -110,6 +112,7 @@ char *process_serial_command(char b) {
|
||||
} else if (b == '\x10') { // ^P
|
||||
paused = !paused;
|
||||
return paused ? "paused" : "resumed";
|
||||
} else if (b == '\x06') { // ^F
|
||||
} else if (b == '\x12') { // ^R
|
||||
reset6502();
|
||||
paused = false;
|
||||
@ -118,11 +121,24 @@ char *process_serial_command(char b) {
|
||||
local_echo = !local_echo;
|
||||
return local_echo ? "local echo enabled" : "local echo disabled";
|
||||
} else if (b == '\x14') { // ^T
|
||||
static uint32_t last_ticks = 0;
|
||||
static uint32_t last_millis = 0;
|
||||
uint32_t hz = 0;
|
||||
if (last_ticks != 0) {
|
||||
uint32_t elapsed_ticks = clockticks6502 - last_ticks;
|
||||
uint32_t elapsed_millis = millis - last_millis;
|
||||
|
||||
if (elapsed_millis != 0) hz = elapsed_ticks * 1000 / elapsed_millis;
|
||||
}
|
||||
|
||||
last_ticks = clockticks6502;
|
||||
last_millis = millis;
|
||||
|
||||
static char buf[64];
|
||||
snprintf(buf, sizeof(buf), "%ld ticks\r\n%ld instructions", clockticks6502, instructions);
|
||||
snprintf(buf, sizeof(buf), "%ld ticks\r\n%ld instructions\r\n%ld Hz", clockticks6502, instructions, hz);
|
||||
return buf;
|
||||
} else if (b == '\x07') { // ^G
|
||||
return "^V=version ^R=reset ^E=echo ^P=pause ^T=ticks ^G=help";
|
||||
return "^V=version ^R=reset ^E=echo ^P=pause ^T=timing ^G=help";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user