shithub: rgbds

Download patch

ref: 3c7e59b9e12355bb3e3ba606bad69a185e2c4afc
parent: b019b0394621c130f53c0db03372ea036700270f
parent: c4471e33009eb038e3d23e1de80dba0a8c0e7973
author: Antonio Niño Díaz <antonio_nd@outlook.com>
date: Sat Aug 17 12:07:28 EDT 2019

Merge pull request #374 from Ben10do/pushs-outside-of-section

Allow PUSHS to be used before a section

--- a/CONTRIBUTORS.rst
+++ b/CONTRIBUTORS.rst
@@ -22,7 +22,7 @@
 Other contributors
 ------------------
 
-- Ben10do
+- Ben Hetherington <dev@ben-h.uk>
 
 - Björn Höhrmann <bjoern@hoehrmann.de>
 
--- a/src/asm/output.c
+++ b/src/asm/output.c
@@ -1,7 +1,7 @@
 /*
  * This file is part of RGBDS.
  *
- * Copyright (c) 1997-2018, Carsten Sorensen and RGBDS contributors.
+ * Copyright (c) 1997-2019, Carsten Sorensen and RGBDS contributors.
  *
  * SPDX-License-Identifier: MIT
  */
@@ -655,7 +655,7 @@
 		fatalerror("Cannot change the section within a UNION");
 
 	pCurrentSection = pSect;
-	nPC = pSect->nPC;
+	nPC = (pSect != NULL) ? pSect->nPC : 0;
 
 	pPCSymbol->nValue = nPC;
 	pPCSymbol->pSection = pCurrentSection;
--- /dev/null
+++ b/test/asm/pops-no-pushed-sections.asm
@@ -1,0 +1,1 @@
+POPS
--- /dev/null
+++ b/test/asm/pops-no-pushed-sections.out
@@ -1,0 +1,2 @@
+ERROR: pops-no-pushed-sections.asm(1):
+    No entries in the section stack
--- /dev/null
+++ b/test/asm/pops-no-pushed-sections.out.pipe
@@ -1,0 +1,2 @@
+ERROR: -(1):
+    No entries in the section stack
--- /dev/null
+++ b/test/asm/pops-restore-no-section.asm
@@ -1,0 +1,10 @@
+PUSHS
+
+SECTION "Test", ROM0
+SomeContent:
+	db 1, 2, 3, 4, 5, 6, 7, 8, 9
+
+POPS
+
+DisallowedContent:
+	db 0
--- /dev/null
+++ b/test/asm/pops-restore-no-section.out
@@ -1,0 +1,2 @@
+ERROR: pops-restore-no-section.asm(10):
+    Code generation before SECTION directive
--- /dev/null
+++ b/test/asm/pops-restore-no-section.out.pipe
@@ -1,0 +1,2 @@
+ERROR: -(10):
+    Code generation before SECTION directive
--- /dev/null
+++ b/test/asm/pushs-outside-section.asm
@@ -1,0 +1,2 @@
+PUSHS
+POPS