From e4cc7006c09e3e9de999ba52507ddd2ba9d58e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Tue, 7 Feb 2023 23:27:23 +0100 Subject: fast ram --- ebs.c | 12 ++++++++++++ makefile | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ebs.c b/ebs.c index 446e92b..401641e 100644 --- a/ebs.c +++ b/ebs.c @@ -19,7 +19,11 @@ typedef uint16_t naslov; */ struct ebs { +#ifdef FAST_RAM + int_fast32_t ram[(RAM_VELIKOST+2)*8]; +#else unsigned char ram[RAM_VELIKOST-2+2]; /**< ne vsebuje programskega števca, ampak vsebuje magic bite */ +#endif unsigned char * pm; unsigned pm_velikost; uint16_t pc; @@ -65,7 +69,11 @@ static bool peek (struct ebs * e, naslov a) { assert(a < RAM_VELIKOST*8+15); if (a < 16) return e->pc & (1 << (15-a)); +#ifdef FAST_RAM + return e->ram[a]; +#else return e->ram[a/8-2] & (1 << (a % 8)); +#endif } /** @@ -85,10 +93,14 @@ static void poke (struct ebs * e, naslov a, bool v) { e->pc &= ~(1 << (15-a)); return; } +#ifdef FAST_RAM + e->ram[a] = v; +#else if (v) e->ram[a/8-2] |= (1 << (a % 8)); else e->ram[a/8-2] &= ~(1 << (a % 8)); +#endif } static struct inštrukcija inštrukcija (struct ebs * e, naslov a) { diff --git a/makefile b/makefile index b183ada..e109eee 100644 --- a/makefile +++ b/makefile @@ -1,6 +1,6 @@ DESTDIR=/ CC=cc -MYCFLAGS=-O3 -DNO_HOOKS -march=native -Wall -Wextra -Wformat -pedantic -g -I. # -fsanitize=address +MYCFLAGS=-O3 -DFAST_RAM -DNO_HOOKS -march=native -Wall -Wextra -Wformat -pedantic -g -I. # -fsanitize=address MYLDFLAGS=-lpthread default: ebs disass -- cgit v1.2.3