This commit is contained in:
Nils Polek 2023-12-09 22:40:18 +01:00
parent 55af679c39
commit 61a138fdee
6 changed files with 28 additions and 2 deletions

View File

@ -1,6 +1,6 @@
#ifndef CONSTS #ifndef CONSTS
#define CONSTS #define CONSTS
#define VERSION 3 #define VERSION 4
#endif /* ifndef CONSTS #endif /* ifndef CONSTS
#define CONSTS #define CONSTS

View File

@ -34,5 +34,8 @@
#define CALL 26 #define CALL 26
#define RET 27 #define RET 27
#define DROP 28 #define DROP 28
#define PUSHR 29
#define POPR 30
#define DUP 31
#endif /* ifndef INSREUKTION */ #endif /* ifndef INSREUKTION */

8
njvm.c
View File

@ -166,7 +166,13 @@ void execute(struct program program) {
i = SIGN_EXTEND(IMMEDIATE(program.program[i])) - 1; i = SIGN_EXTEND(IMMEDIATE(program.program[i])) - 1;
if (debug == 1) printf("new i: %i\n", i); if (debug == 1) printf("new i: %i\n", i);
break; break;
} case CALL:
push(stack, i+1);
break;
case RET:
i = pop(stack);
break;
}
} }
end: end:
return; return;

Binary file not shown.

17
programs/prog7.asm Normal file
View File

@ -0,0 +1,17 @@
//
// prog04.asm -- call/ret with args, and with ret value
//
pushc 12
rdint
mul
wrint
call proc
halt
proc:
asf 0
pushc '\n'
wrchr
rsf
ret

BIN
programs/prog7.bin Normal file

Binary file not shown.