Merge pull request #60 from olsner/struc_base

Implement the base offset parameter for the struc macro
diff --git a/modules/parsers/nasm/nasm-std.mac b/modules/parsers/nasm/nasm-std.mac
index 3c9223a..bb6e5c4 100644
--- a/modules/parsers/nasm/nasm-std.mac
+++ b/modules/parsers/nasm/nasm-std.mac
@@ -25,14 +25,14 @@
 	  __SECT__
 %endmacro
 
-%imacro struc 1.nolist
+%imacro struc 1-2.nolist 0
 %push struc
 %define %$strucname %1
-[absolute 0]
+[absolute %2]
 %$strucname:			; allow definition of `.member' to work sanely
 %endmacro 
 %imacro endstruc 0.nolist
-%{$strucname}_size:
+%{$strucname}_size EQU $ - %$strucname
 %pop
 __SECT__
 %endmacro
diff --git a/modules/parsers/nasm/tests/Makefile.inc b/modules/parsers/nasm/tests/Makefile.inc
index e8293d2..56d0b92 100644
--- a/modules/parsers/nasm/tests/Makefile.inc
+++ b/modules/parsers/nasm/tests/Makefile.inc
@@ -39,6 +39,8 @@
 EXTRA_DIST += modules/parsers/nasm/tests/strucalign.hex
 EXTRA_DIST += modules/parsers/nasm/tests/struczero.asm
 EXTRA_DIST += modules/parsers/nasm/tests/struczero.hex
+EXTRA_DIST += modules/parsers/nasm/tests/strucbase.asm
+EXTRA_DIST += modules/parsers/nasm/tests/strucbase.hex
 EXTRA_DIST += modules/parsers/nasm/tests/syntax-err.asm
 EXTRA_DIST += modules/parsers/nasm/tests/syntax-err.errwarn
 EXTRA_DIST += modules/parsers/nasm/tests/uscore.asm
diff --git a/modules/parsers/nasm/tests/strucbase.asm b/modules/parsers/nasm/tests/strucbase.asm
new file mode 100644
index 0000000..81e2fc0
--- /dev/null
+++ b/modules/parsers/nasm/tests/strucbase.asm
@@ -0,0 +1,11 @@
+struc base, -7
+.a: resb 1
+.b: resb 1
+endstruc
+
+; Expect base and base.a to appear at -7, base.b at -6
+db base
+db base.a
+db base.b
+; The size should be '2' here
+db base_size
diff --git a/modules/parsers/nasm/tests/strucbase.hex b/modules/parsers/nasm/tests/strucbase.hex
new file mode 100644
index 0000000..5d48c5e
--- /dev/null
+++ b/modules/parsers/nasm/tests/strucbase.hex
@@ -0,0 +1,4 @@
+f9 
+f9 
+fa 
+02