diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2023-02-07 23:27:23 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2023-02-07 23:27:23 +0100 |
commit | e4cc7006c09e3e9de999ba52507ddd2ba9d58e49 (patch) | |
tree | 948da42b826aa320fee877bda519da64c277e09f | |
parent | optimization to allow clang (diff) | |
download | ebs-e4cc7006c09e3e9de999ba52507ddd2ba9d58e49.tar ebs-e4cc7006c09e3e9de999ba52507ddd2ba9d58e49.tar.gz ebs-e4cc7006c09e3e9de999ba52507ddd2ba9d58e49.tar.bz2 ebs-e4cc7006c09e3e9de999ba52507ddd2ba9d58e49.tar.lz ebs-e4cc7006c09e3e9de999ba52507ddd2ba9d58e49.tar.xz ebs-e4cc7006c09e3e9de999ba52507ddd2ba9d58e49.tar.zst ebs-e4cc7006c09e3e9de999ba52507ddd2ba9d58e49.zip |
-rw-r--r-- | ebs.c | 12 | ||||
-rw-r--r-- | makefile | 2 |
2 files changed, 13 insertions, 1 deletions
@@ -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) { @@ -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 |