nrj-oisc

NOR and Reference Jump OISC platform
git clone git://git.luxferre.top/nrj-oisc.git
Log | Files | Refs | README

commit c19a47877c9ba3fbdb5a49026d24d3a0cf81783c
parent 570646b8dd5c5d4834d1c4014fe1fd98dd1b3479
Author: Luxferre <lux@ferre>
Date:   Sun, 21 Aug 2022 20:10:03 +0300

Nor and Reference Jump

Diffstat:
Mnrj.c | 27++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/nrj.c b/nrj.c @@ -68,21 +68,18 @@ void nrj_load(NRJWORD* m, NRJWORD offset, char *fname) { } void nrj_run(char *program) { - NRJWORD maxaddr = (NRJWORD) (NRJSIZE - 1), mem[NRJSIZE], a, b, c; - mem[0] = (NRJWORD) 4; - mem[1] = mem[2] = mem[3] = (NRJWORD) 0; - nrj_load(mem, mem[0], program); - while(mem[0] != maxaddr) { - if(mem[1]) nrj_in(&mem[3], &mem[mem[1]]); - a = mem[0]++; - b = mem[0]++; - c = mem[0]++; - mem[a] = (~(mem[a] | mem[b])) & maxaddr; - mem[0] = (mem[0] + mem[c]) & maxaddr; - mem[1] = (NRJWORD) 0; - if(mem[2]) { - nrj_out(&mem[3], &mem[mem[2]]); - mem[2] = (NRJWORD) 0; + NRJWORD maxaddr = (NRJWORD) (NRJSIZE - 1), mem[NRJSIZE], pc; + mem[0] = mem[1] = mem[2] = (NRJWORD) 0; + pc = (NRJWORD) 3; + nrj_load(mem, pc, program); + while(pc != maxaddr) { + if(mem[0]) nrj_in(&mem[2], &mem[mem[0]]); + mem[mem[pc]] = (~(mem[mem[pc]] | mem[mem[pc+1]])) & maxaddr; + pc = mem[mem[pc+2]]; + mem[0] = (NRJWORD) 0; + if(mem[1]) { + nrj_out(&mem[2], &mem[mem[1]]); + mem[1] = (NRJWORD) 0; } } }