add: end instruction
This commit is contained in:
@@ -82,6 +82,7 @@ The syntax is very close to x86 Intel Assembly. Here is a list of the operands a
|
||||
| **jna** foo | Jumps to `foo` if `cmp` didn't return `CMP_ABOVE` | no |
|
||||
| **jmp** foo | Jumps to `foo` | no |
|
||||
| **ret** | Returns from the callee to the caller | no |
|
||||
| **end** | Ends the program | no |
|
||||
| **pop** a1 | Pops the first element of the stack into a1 | no |
|
||||
| **push** 69 | Pushes the value 69 to the top of the stack | no |
|
||||
| **call** put | Calls the `put` API | yes/no |
|
||||
|
||||
@@ -276,3 +276,7 @@ void xor () {
|
||||
|
||||
eax = get_value(args->arg1) ^ get_value(args->arg2);
|
||||
}
|
||||
|
||||
void end() {
|
||||
exit_code = 1;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ void push();
|
||||
void call();
|
||||
void and();
|
||||
void xor();
|
||||
void end();
|
||||
|
||||
static const command_t command_map[] = {
|
||||
{.command = "add", .fptr = add},
|
||||
@@ -75,6 +76,7 @@ static const command_t command_map[] = {
|
||||
{.command = "call", .fptr = call},
|
||||
{.command = "and", .fptr = and},
|
||||
{.command = "xor", .fptr = xor},
|
||||
{.command = "end", .fptr = end},
|
||||
|
||||
{.command = NULL, .fptr = NULL}
|
||||
};
|
||||
|
||||
@@ -152,10 +152,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
if (exit_code) {
|
||||
free(args->arg1);
|
||||
free(args->arg2);
|
||||
free(args);
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
++line_number;
|
||||
|
||||
Reference in New Issue
Block a user