60
60
OR ,XOR ,AND ,EQ ,NE ,LT ,GT ,LE ,GE ,SHL ,SHR ,ADD ,SUB ,MUL ,DIV ,MOD ,
61
61
// C functions
62
62
OPEN ,READ ,CLOS ,PRTF ,DPRT ,MALC ,FREE ,MSET ,MCMP ,EXIT ,FDSZ ,
63
+ GETC ,PUTC ,
63
64
// Platform related functions
64
65
PINI ,RPTH ,PLGT ,
65
66
// VM related functions
@@ -78,6 +79,7 @@ void setup_opcodes() {
78
79
"SC ,PSH ,OR ,XOR ,AND ,EQ ,NE ,LT ,GT ,LE ,GE ,SHL ,"
79
80
"SHR ,ADD ,SUB ,MUL ,DIV ,MOD ,"
80
81
"OPEN,READ,CLOS,PRTF,DPRT,MALC,FREE,MSET,MCMP,EXIT,FDSZ,"
82
+ "GETC,PUTC" ,
81
83
"PINI,RPTH,PLGT,"
82
84
"PCHG,"
83
85
"SYS1,SYS2,SYS3,SYS4,SYS5,SYS6,SYSI,SYSM" ;
@@ -91,6 +93,7 @@ void setup_symbols() {
91
93
"char else enum if int return sizeof include while "
92
94
// C functions
93
95
"open read close printf dprintf malloc free memset memcmp exit fdsize "
96
+ "getchar putchar "
94
97
// Dynamic runtime platform functions
95
98
"platform_init runtime_path platform_get "
96
99
"process_changed "
@@ -902,6 +905,8 @@ int run_cycle(int *process, int cycles) {
902
905
process [B_exitcode ] = * sp ;
903
906
rem_cycle = 0 ;
904
907
}
908
+ else if (i == GETC ) { a = (int )getchar (); }
909
+ else if (i == PUTC ) { a = putchar (* sp ); }
905
910
else if (i == SYS1 ) { a = (int )syscall1 (* sp ); }
906
911
else if (i == SYS2 ) { a = (int )syscall2 (sp [1 ], * sp ); }
907
912
else if (i == SYS3 ) { a = (int )syscall3 (sp [2 ], sp [1 ], * sp ); }
0 commit comments