From d3b9fe14a08aea641692a692b1bed0af96a61dd3 Mon Sep 17 00:00:00 2001
From: David Schmenk <dschmenk@sbcglobal.net>
Date: Sat, 24 Feb 2024 11:25:07 -0800
Subject: [PATCH] Add new ASM build tools/files

---
 src/mkrel                  |  9 +++++++--
 src/samplesrc/testasm.pla  | 11 +++++++++++
 src/vmsrc/apple/cmdjit.pla |  4 ++--
 3 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 src/samplesrc/testasm.pla

diff --git a/src/mkrel b/src/mkrel
index a1672a2..00093b5 100755
--- a/src/mkrel
+++ b/src/mkrel
@@ -123,8 +123,12 @@ cp samplesrc/APPLE3.PIX#060000 prodos/demos/apple3/APPLE3.PIX.BIN
 
 rm -rf prodos/bld
 mkdir prodos/bld
-cp rel/PLASM#FE1000        prodos/bld/PLASM.REL
-cp rel/CODEOPT#FE1000      prodos/bld/CODEOPT.REL
+cp rel/PLASM#FE1000              prodos/bld/PLASM.REL
+cp rel/CODEOPT#FE1000            prodos/bld/CODEOPT.REL
+cp ../sysfiles/EDASM#FF2000      prodos/bld/EDASM.SYS
+cp ../sysfiles/EDASM.ASM#063000  prodos/bld/EDASM.ASM.BIN
+cp ../sysfiles/EDASM.ED#063000   prodos/bld/EDASM.ED.BIN
+cp ../sysfiles/EDASM.SWAP#062000 prodos/bld/EDASM.SWAP.BIN
 
 mkdir prodos/bld/samples
 cp samplesrc/hello.pla     prodos/bld/samples/HELLO.PLA.TXT
@@ -155,6 +159,7 @@ cp utilsrc/apple/zipchip.pla prodos/bld/samples/ZIPCHIP.PLA.TXT
 cp libsrc/apple/dhgrlib.pla prodos/bld/samples/DHGR.PLA.TXT
 cp samplesrc/testrel.asm    prodos/bld/samples/TESTREL.ASM.TXT
 cp samplesrc/testext.asm    prodos/bld/samples/TESTEXT.ASM.TXT
+cp samplesrc/testasm.pla    prodos/bld/samples/TESTASM.PLA.TXT
 
 mkdir prodos/bld/scripts
 cp scripts/rod.4th        prodos/bld/scripts/ROD.4TH.TXT
diff --git a/src/samplesrc/testasm.pla b/src/samplesrc/testasm.pla
new file mode 100644
index 0000000..42b7e89
--- /dev/null
+++ b/src/samplesrc/testasm.pla
@@ -0,0 +1,11 @@
+include "inc/cmdsys.plh"
+import test
+  predef hello#0
+  predef goodbye#0
+end
+
+hello
+puts("Did it load?\n")
+goodbye
+hello
+done
diff --git a/src/vmsrc/apple/cmdjit.pla b/src/vmsrc/apple/cmdjit.pla
index e0e0714..4f96c78 100755
--- a/src/vmsrc/apple/cmdjit.pla
+++ b/src/vmsrc/apple/cmdjit.pla
@@ -947,13 +947,13 @@ def allocxheap(size)#1
     word xaddr
     xaddr = xheap
     xheap = xheap + size
-    if systemflags & (restxt1 | resxtxt1)
+    if systemflags & resxtxt1
         if uword_islt(xaddr, $0800) and uword_isgt(xheap, $0400)
             xaddr = $0800
             xheap = xaddr + size
         fin
     fin
-    if systemflags & (restxt2 | resxtxt2)
+    if systemflags & resxtxt2
         if uword_islt(xaddr, $0C00) and uword_isgt(xheap, $0800)
             xaddr = $0C00
             xheap = xaddr + size