From 3e1e67997573ee009808588a6e536c5cb5f71e2d Mon Sep 17 00:00:00 2001 From: ALittlePatate Date: Fri, 19 Jan 2024 23:15:36 +0100 Subject: [PATCH] add: jump to relative line number --- docs/documentation.md | 1 + src/instructions.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/docs/documentation.md b/docs/documentation.md index 29aa3a7..25584f6 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -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 | | **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).
All the operands are case-sensitive, meaning that `ADD` will be an invalid operand.
Please note that additional operands will be added in the future. diff --git a/src/instructions.c b/src/instructions.c index 6c9317d..00268b5 100644 --- a/src/instructions.c +++ b/src/instructions.c @@ -140,6 +140,11 @@ void jmp() { return; } } + int line_off = atoi(state->args->arg1); + if (line_off) { + state->curr_line += line_off; + return; + } state->last_jmp_code = 1; return;