aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/main.c b/main.c
index ce1caa0..978669c 100644
--- a/main.c
+++ b/main.c
@@ -395,14 +395,12 @@ assemblemem(const Memarg* memarg, Rex rex, VarBytes prefix, VarBytes opcode,
/* Case when we don't need sib */
if (memarg->index == ASM_NO_REG && memarg->scale == 0 && ((rm & 7) != 4)) {
- if (memarg->disp.l == 0 && memarg->disp.c == 0) {
- if ((rm & 7) == 5) {
- mod = 1;
- } else {
- mod = 0;
- }
- } else {
+ if (memarg->disp.l != NULL || memarg->disp.c > INT8_MAX || memarg->disp.c < INT8_MIN) {
mod = 2;
+ } else if (memarg->disp.c != 0 || (rm & 7) == 5) {
+ mod = 1;
+ } else {
+ mod = 0;
}
assemblevbytes(prefix);
@@ -505,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;