Pull stuff in again #17

Merged
max merged 6 commits from master into unstable 2026-01-22 14:07:37 +11:00
2 changed files with 28 additions and 0 deletions
Showing only changes of commit a3ca979133 - Show all commits

View File

@@ -114,6 +114,7 @@ Supported instructions so far:
* inequal * inequal
* greater * greater
* lesser * lesser
* not
* jump * jump
* if * if
* @ (label creation) * @ (label creation)

View File

@@ -221,6 +221,33 @@ char* compileGroundProgram(GroundProgram* program) {
break; break;
} }
case NOT: {
if (gi.args.length < 2) {
runtimeError(TOO_FEW_ARGS, "Expecting 2 args", &gi, i);
}
if (gi.args.length > 2) {
runtimeError(TOO_MANY_ARGS, "Expecting 2 args", &gi, i);
}
if (gi.args.args[0].type != VALUE && gi.args.args[0].type != VALREF) {
runtimeError(ARG_TYPE_MISMATCH, "Expecting an Int (for now) for arg 1", &gi, i);
}
if (gi.args.args[1].type != DIRREF) {
runtimeError(ARG_TYPE_MISMATCH, "Expecting a DirectRef", &gi, i);
}
char* varName = gi.args.args[1].value.refName;
APPEND_ESTR(start, " ; not\n");
APPEND_ESTR(start, " mov rax, ");
APPEND_ESTR(start, processValueString(gi.args.args[0]));
APPEND_ESTR(start, "\n");
APPEND_ESTR(start, " xor rax, 1\n");
APPEND_ESTR(start, " mov [");
APPEND_ESTR(start, varName);
APPEND_ESTR(start, "], rax\n");
break;
}
case ADD: { case ADD: {
if (gi.args.length < 3) { if (gi.args.length < 3) {
runtimeError(TOO_FEW_ARGS, "Expecting 2 args for add instruction", &gi, i); runtimeError(TOO_FEW_ARGS, "Expecting 2 args for add instruction", &gi, i);