changeset 58:bed2d84eeabe

Fix ldimh special casing of loading labels for the case when the label is not a forward reference
author Michael Pavone <pavone@retrodev.com>
date Tue, 06 Sep 2016 09:42:31 -0700
parents c44170825b16
children b15187a99d6f
files src/asm.c
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/asm.c	Thu Sep 01 21:52:48 2016 -0700
+++ b/src/asm.c	Tue Sep 06 09:42:31 2016 -0700
@@ -354,7 +354,11 @@
 			l = add_label(meta, arg, 0, 0);
 		}
 		if (l->valid) {
-			value = l->address;
+			if (*inst == LDIMH) {
+				value = l->address >> 8;
+			} else {
+				value = l->address;
+			}
 		} else {
 			value = 0;
 			add_reference(l, pc, (*inst & 0xF) == LDIMH ? IMMEDHI : (*inst & 0xF) == LDIM ? IMMED8 : IMMED4);