diff --git a/instructions.c b/instructions.c index 410fd28..7db37df 100644 --- a/instructions.c +++ b/instructions.c @@ -135,7 +135,7 @@ const struct instruction instructions[NR_OPCODES] = { OP(A_FILL, 0), OP(C_REF, 0), OP(C_ASSIGN, 0), - OP(MSG, 0), // TODO + JMP(MSG, 1, INSTR_INT), OP(CALLHLL, 2, INSTR_INT, INSTR_INT), OP(PUSHSTRUCTPAGE, 0), JMP(CALLMETHOD, 1, INSTR_FUN), diff --git a/test/Source/lang.jaf b/test/Source/lang.jaf index c0eadb2..5caf416 100755 --- a/test/Source/lang.jaf +++ b/test/Source/lang.jaf @@ -120,4 +120,17 @@ void test_lang(void) test_equal("string switch (no default)", test_string_switch("d"), 100); test_equal("string switch (default)", test_string_switch_default("d"), 100); test_equal("local ref escape", (set_page_ref(42), gi), 42); + 'message1'; + 'message2'; +} + +int msg_count = 0; + +void message(int msg_nr, int nr_messages, string msg) +{ + if (msg_count == 0) + test_string("message1", msg, "message1"); + else if (msg_count == 1) + test_string("message2", msg, "message2"); + msg_count++; } diff --git a/vm.c b/vm.c index 2225585..8b6c257 100644 --- a/vm.c +++ b/vm.c @@ -626,6 +626,14 @@ static void execute_instruction(int16_t opcode) case SJUMP: scenario_call(stack_pop().i); break; + case MSG: + if (ain->msgf < 0) + break; + stack_push(get_argument(0)); + stack_push(ain->nr_messages); + stack_push_string(string_ref(ain->messages[get_argument(0)])); + function_call(ain->msgf, instr_ptr + instruction_width(MSG)); + break; case JUMP: // ADDR instr_ptr = get_argument(0); break;