First working assembler!

This commit is contained in:
Luxferre
2022-09-02 19:57:59 +03:00
parent f560cc5cbd
commit d712730bb4
4 changed files with 281 additions and 2 deletions
+2 -2
View File
@@ -41,7 +41,7 @@ void nrj_run(NRJWORD *mem, NRJWORD pc) { /* Main NRJ engine - just 12 lines of C
mem[mem[pc]] = (~(mem[mem[pc]] | mem[mem[pc+1]])) & MAXADDR; /* then perform the NOR operation */
pc = mem[mem[pc+2]]; /* then perform the reference jump operation */
if(mem[1]) { /* then handle output if word 1 is set */
nrj_out(&mem[2], &mem[mem[1]]); /* output the value from the location specified in word 1 */
nrj_out(&mem[2], &mem[1]); /* output the value from the word 1 */
mem[1] = (NRJWORD) 0; /* clear word 1 */
}
}
@@ -58,7 +58,7 @@ int main(int argc, char* argv[]) { /* emulator entry point: nrj program.bin */
fseek(prog, 0, SEEK_END);
int flen = ftell(prog);
fseek(prog, 0, SEEK_SET);
fread(mem, sizeof(NRJWORD), (flen/sizeof(NRJWORD)) & MAXADDR, prog);
fread(mem, sizeof(NRJWORD), flen/sizeof(NRJWORD), prog);
fclose(prog);
tcgetattr(0, &tty_opts_backup);
atexit(&restore_term);