From 936dd9a97e454747f8783fda8f1ee0c13d3f991d Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Tue, 19 Oct 2021 13:47:31 -0700 Subject: Consider change in instruction size when calculating jump distance. If we previously used a 4-byte offset, the instruction is 4 bytes larger than if we were to use a 1 byte offset. Therefore, an instruction whose previous offset was 0x83 should still be eligible for 1 byte encoding. --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 8f17d17..978669c 100644 --- a/main.c +++ b/main.c @@ -503,7 +503,7 @@ assemblejmp(const Jmp* j) } else { distance = target->wco - cursection->hdr.sh_size; } - if ((distance - 1) >= -128 && (distance - 1) <= 127) { + if ((distance - 1) >= -128 && (distance - 5) <= 127) { jmpsize = 1; } else { jmpsize = 4; -- cgit v1.2.3