Skip to content

Instantly share code, notes, and snippets.

@realmonster
Created October 7, 2017 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save realmonster/09b1bd1e4cc9e033a2ad4459159327a3 to your computer and use it in GitHub Desktop.
Save realmonster/09b1bd1e4cc9e033a2ad4459159327a3 to your computer and use it in GitHub Desktop.
vasm make abs short optimization
From 0ff1b130dce84b48b65927bde7cd433ee4649228 Mon Sep 17 00:00:00 2001
From: realmonster <r57shell@uralweb.ru>
Date: Sat, 7 Oct 2017 18:40:49 +0500
Subject: [PATCH] short
---
cpu.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/cpu.c b/cpu.c
index 916c589..fa0360e 100644
--- a/cpu.c
+++ b/cpu.c
@@ -2131,7 +2131,7 @@ static void optimize_oper(operand *op,struct optype *ot,section *sec,
cpu_error(50,"abs.w->abs.l");
}
else if (op->base[0]) {
- if (typechk && LOCREF(op->base[0])) {
+ if (typechk && LOCREF(op->base[0]) && !size16[0]) {
/* label.w --> label.l */
op->reg = REG_AbsLong;
if (final)
@@ -2141,12 +2141,16 @@ static void optimize_oper(operand *op,struct optype *ot,section *sec,
}
else if (op->mode==MODE_Extended && op->reg==REG_AbsLong) {
- if (opt_abs && !op->base[0] && size16[0] &&
+ if (opt_abs && (!op->base[0] || (op->base[0] && LOCREF(op->base[0]))) && size16[0] &&
(ot->modes & (1<<AM_AbsShort))) {
/* absval.l --> absval.w */
op->reg = REG_AbsShort;
- if (final && warn_opts>1)
- cpu_error(49,"abs.l->abs.w");
+ if (final && warn_opts>1) {
+ if (op->base[0])
+ cpu_error(49,"(!check!) abs.l->abs.w");
+ else
+ cpu_error(49,"abs.l->abs.w");
+ }
}
else if (sdreg>=0 && op->base[0]!=NULL &&
(ot->modes & (1<<AM_An16Disp)) &&
--
1.8.1.msysgit.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment