aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorAndrew Chambers <[email protected]>2021-10-14 22:39:39 +1300
committerAndrew Chambers <[email protected]>2021-10-14 22:39:39 +1300
commita66c85675226c82d1ec0e9cf22fdcff552e406d7 (patch)
tree72092f6527eb78fbeae3723537d28765c4f998e7 /main.c
parentec403dd16c5b417086e63faee5912b78a1ffeb59 (diff)
Use short address displacement when possible.
Diffstat (limited to 'main.c')
-rw-r--r--main.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/main.c b/main.c
index dd3c3db..1d88fe8 100644
--- a/main.c
+++ b/main.c
@@ -372,11 +372,11 @@ static void assemblemem(const Memarg *memarg, uint8_t rexw, VarBytes prefix,
base = rm;
rm = 4;
- // TODO: if our disp fits in a +disp8, use that instead.
if (memarg->disp.c == 0 && memarg->disp.l == 0 && ((base & 7) != 5)) {
mod = 0; /* +0 */
} else {
- if (memarg->disp.c == 0 && memarg->disp.l == 0) {
+ if (memarg->disp.l == NULL && memarg->disp.c >= -128 &&
+ memarg->disp.c <= 127) {
mod = 1; /* +disp8 */
} else {
mod = 2; /* +disp32 */