versin v
This commit is contained in:
parent
55af679c39
commit
61a138fdee
2
consts.c
2
consts.c
@ -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
|
||||||
|
|||||||
@ -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
8
njvm.c
@ -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;
|
||||||
|
|||||||
BIN
programs/nja
BIN
programs/nja
Binary file not shown.
17
programs/prog7.asm
Normal file
17
programs/prog7.asm
Normal 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
BIN
programs/prog7.bin
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user