add: jump to relative line number

This commit is contained in:
2024-01-19 23:15:36 +01:00
parent 011d748a45
commit 3e1e679975
2 changed files with 6 additions and 0 deletions

View File

@@ -88,6 +88,7 @@ The syntax is very close to x86 Intel Assembly. Here is a list of the operands a
| **push** 69 | Pushes the value 69 to the top of the stack | no | | **push** 69 | Pushes the value 69 to the top of the stack | no |
| **call** put | Calls the `put` API | yes/no | | **call** put | Calls the `put` API | yes/no |
All the `jmp`-related operands (`je`, `jna`, ...) can have a number as argument, this way the program will jump to `x` lines (ex: `jmp 3` will jump 3 lines down).<br>
All the operands are case-sensitive, meaning that `ADD` will be an invalid operand.<br> All the operands are case-sensitive, meaning that `ADD` will be an invalid operand.<br>
Please note that additional operands will be added in the future. Please note that additional operands will be added in the future.

View File

@@ -140,6 +140,11 @@ void jmp() {
return; return;
} }
} }
int line_off = atoi(state->args->arg1);
if (line_off) {
state->curr_line += line_off;
return;
}
state->last_jmp_code = 1; state->last_jmp_code = 1;
return; return;