summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2023-02-07 23:27:23 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2023-02-07 23:27:23 +0100
commite4cc7006c09e3e9de999ba52507ddd2ba9d58e49 (patch)
tree948da42b826aa320fee877bda519da64c277e09f
parentoptimization to allow clang (diff)
downloadebs-master.tar
ebs-master.tar.gz
ebs-master.tar.bz2
ebs-master.tar.lz
ebs-master.tar.xz
ebs-master.tar.zst
ebs-master.zip
-rw-r--r--ebs.c12
-rw-r--r--makefile2
2 files changed, 13 insertions, 1 deletions
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