1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-04-09 16:40:38 +00:00

Merge pull request #18 from dschmenk/master

Merge latest upstream changes to master
This commit is contained in:
ZornsLemma 2023-01-14 22:30:39 +00:00 committed by GitHub
commit 156bca2413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 504 additions and 486 deletions

View File

@ -1,7 +1,9 @@
# 7/4/2020 PLASMA 2.0 Alpha 1 Available!
# 1/1/2023 PLASMA 2.0 Alpha 2 Available!
Let's start 2023 off with some critical bug fixes.
[Download and read the Release Notes](https://github.com/dschmenk/PLASMA/releases)
[Change List](https://github.com/dschmenk/PLASMA/blob/master/doc/Version%202.0.md#changes-in-plasma-for-20-alpha-1)
[Change List](https://github.com/dschmenk/PLASMA/blob/master/doc/Version%202.0.md#changes-in-plasma-for-20-alpha-2)
# 4/29/2018 PLASMA 1.2 Available!
[Download and read the Release Notes](https://github.com/dschmenk/PLASMA/blob/master/doc/Version%201.2.md)

View File

@ -1,20 +1,20 @@
# PLASMA Version 2.0 Alpha 1
# PLASMA Version 2.0 Alpha 2
Welcome to PLASMA: the Grand Unifying Platform for the Apple 1, ][, and ///.
Download the five disk images:
[PLASMA 2.0 Alpha1 800K Full System](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2.2mg?raw=true)
[PLASMA 2.0 Alpha2 800K Full System](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2.2mg?raw=true)
[PLASMA 2.0 Alpha1 System and ProDOS Boot](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2-SYS.PO?raw=true)
[PLASMA 2.0 Alpha2 System and ProDOS Boot](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2-SYS.PO?raw=true)
[PLASMA 2.0 Alpha1 Build Tools](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2-BLD.PO?raw=true)
[PLASMA 2.0 Alpha2 Build Tools](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2-BLD.PO?raw=true)
[PLASMA 2.0 Alpha1 Demos](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2-DEM.PO?raw=true)
[PLASMA 2.0 Alpha2 Demos](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2-DEM.PO?raw=true)
[PLASMA 2.0 Alpha1 TCP/IP network modules](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2-INET.PO?raw=true)
[PLASMA 2.0 Alpha2 TCP/IP network modules](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2-INET.PO?raw=true)
[PLASMA 2.0 Alpha1 Apple /// SOS Mame Boot and SANE floating point modules](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2-FPSOS.PO?raw=true)
[PLASMA 2.0 Alpha2 Apple /// SOS Mame Boot and SANE floating point modules](https://github.com/dschmenk/PLASMA/blob/master/images/apple/PLASMA2-FPSOS.PO?raw=true)
[PLASMA 2.0 Alpha1 Apple /// Mame hard disk image](https://github.com/dschmenk/PLASMA/blob/master/images/apple/apple3.hd?raw=true)
@ -118,6 +118,14 @@ There is a [YouTube playlist](https://www.youtube.com/playlist?list=PLlPKgUMQbJ7
- The documentation is sparse and incomplete. Yep, could use your help...
# Changes in PLASMA for 2.0 Alpha 2
1. Self hosted compiler fixes for invalid array size constants
2. Ensure IDs in self hosted compiler are 31 characters significant
3. Fix bug COPY file parsing and move common routine into MATCHFILES
# Changes in PLASMA for 2.0 Alpha 1
1. Improved entry/exit for 128K Apple IIe //c

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,4 +2,5 @@ import matchfiles
predef matchName(src, exp)#1
predef matchList(pathptr, exp)#2
predef isWildName(exp)#1
predef fileFromPath(filestr, pathstr)#0
end

View File

@ -1,4 +1,5 @@
include "inc/cmdsys.plh"
include "inc/conio.plh"
sysflags nojitc // Keep tone() from compiling and sounding different
//
// Handy constants.
@ -34,24 +35,6 @@ const page2 = 1
//
const ENV_REG = $FFDF
//
// External interface.
//
struc t_conio
word keypressed
word getkey
word echo
word home
word gotoxy
word viewport
word texttype
word textmode
word grmode
word grcolor
word grplot
word tone
word rnd
end
//
// Predefined functions.
//
predef a2keypressed,a2home,a12echo(state),a2gotoxy(x,y),a2viewport(left, top, width, height),a2texttype(type)

View File

@ -1,4 +1,5 @@
include "inc/cmdsys.plh"
include "inc/fileio.plh"
//
// CFFA1 addresses.
//
@ -22,26 +23,6 @@ const sysbuf = $0800
//
// External interface
//
struc t_fileio
word getpfx
word setpfx
word getfileinfo
word setfileinfo
word geteof
word seteof
word iobufalloc
word open
word close
word read
word write
word create
word destroy
word rename
word newline
word online
word readblock
word writeblock
end
predef a2getpfx(path), a23setpfx(path), a2getfileinfo(path, fileinfo), a2setfileinfo(path, fileinfo), a23geteof(refnum)#2, a23seteof(refnum, eofl, eofh), a2iobufs(iobufs), a2open(path), a2close(refnum)
predef a23read(refnum, buf, len), a2write(refnum, buf, len), a2create(path, type, aux), a23destroy(path), a23rename(path, newpath)
predef a2newline(refnum, emask, nlchar), a2online(unit, buf), a2readblock(unit, buf, block), a2writeblock(unit, buf, block)
@ -209,9 +190,9 @@ def a13iobufs(iobufs)
end
def a2open(path)
byte i, params[6]
for i = 0 to MAX_IOBUFS-1
if iobuf_addr[i] and not iobuf_ref[i]
if iobuf_addr[i] and not iobuf_ref[i]
params.0 = 3
params:1 = path
params:3 = iobuf_addr[i]
@ -396,7 +377,7 @@ def a3volume(unit, volname)
byte devname[17]
byte info[11]
byte params[9]
^volname = 0
params.0 = 4
params.1 = unit

View File

@ -15,7 +15,7 @@ def matchNext(src, srcofst, exp, expofst)
return TRUE
fin
is '?' // Single char wildcard
if ^src >= srcofst
if ^src >= srcofst
return matchNext(src, srcofst + 1, exp, expofst + 1)
fin
return FALSE
@ -103,7 +103,7 @@ end
//
export def isWildName(exp)#1
byte i
if ^exp
for i = 1 to ^exp
if exp->[i] == '*' or exp->[i] == '?'
@ -113,5 +113,18 @@ export def isWildName(exp)#1
fin
return FALSE
end
//
// Utility routine to separate filename from path
//
export def fileFromPath(filestr, pathstr)#0
byte i
for i = ^pathstr downto 1
if pathstr->[i] == '/'
break
fin
next
^filestr = ^pathstr - i
memcpy(filestr + 1, pathstr + 1 + i, ^filestr)
end
done

View File

@ -1,24 +1,5 @@
include "inc/cmdsys.plh"
//
// iNet API - must match inet.plh
//
struc t_inet
word initIP
word serviceIP
word openUDP
word sendUDP
word closeUDP
word listenTCP
word connectTCP
word sendTCP
word closeTCP
word setInterfaceIP
word getInterfaceHA
word setDNS
word resolveIP
word setCallback
word setParam
end
include "inc/inet.plh"
//
// DNS message
//

View File

@ -76,6 +76,7 @@ ROGUE = rel/ROGUE\#FE1000
ROGUEMAP = rel/ROGUEMAP\#FE1000
ROGUECOMBAT= rel/ROGUECOMBAT\#FE1000
MON = rel/apple/MON\#FE1000
CONIOTST = rel/apple/CONIOTST\#FE1000
TILETEST = rel/apple/TILETEST\#FE1000
HGRTEST = rel/apple/HGRTEST\#FE1000
GRTEST = rel/apple/GRTEST\#FE1000
@ -109,11 +110,11 @@ TXTTYPE = .TXT
#SYSTYPE = \#FF2000
#TXTTYPE = \#040000
apple: $(PLVMZP_APL) $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVMJIT) $(PLVM802) $(PLVM03) $(PLVMJIT03) $(CMD) $(CMDJIT) $(JIT) $(JIT16) $(JITUNE) $(SOSCMD) $(SOSCMDJIT) $(PLASMAPLASM) $(CODEOPT) $(ZIPCHIP) $(MATCHFILES) $(ARGS) $(MEMMGR) $(MEMTEST) $(FIBER) $(FIBERTEST) $(LONGJMP) $(ED) $(MON) $(COPY) $(DEL) $(REN) $(CAT) $(NEWDIR) $(TYPE) $(SOS) $(ROD) $(SIEVE) $(PRIMEGAP) $(MOUSE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(TFTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(SFM) $(SFMSPRT) $(GRAFIX) $(GFXDEMO) $(LINES) $(HGRTILE) $(HGRFONT) $(HGRSPRITE) $(HGRLIB) $(TILETEST) $(HGRTEST) $(GRLIB) $(DGRLIB) $(GRTEST) $(DGRTEST) $(HGRTEST) $(FILEIO_APL) $(CONIO_APL) $(JOYBUZZ) $(PORTIO) $(SPIPORT) $(SDFAT) $(FATCAT) $(FATGET) $(FATPUT) $(FATWDSK) $(FATRDSK) $(INT32) $(INT32TEST) $(SANE) $(FPSTR) $(FPU) $(SANITY) $(LZ4) $(LZ4CAT) $(RPNCALC) $(SNDSEQ) $(PLAYSEQ)
apple: $(PLVMZP_APL) $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVMJIT) $(PLVM802) $(PLVM03) $(PLVMJIT03) $(CMD) $(CMDJIT) $(JIT) $(JIT16) $(JITUNE) $(SOSCMD) $(SOSCMDJIT) $(PLASMAPLASM) $(CODEOPT) $(ZIPCHIP) $(MATCHFILES) $(ARGS) $(MEMMGR) $(MEMTEST) $(FIBER) $(FIBERTEST) $(LONGJMP) $(ED) $(MON) $(COPY) $(DEL) $(REN) $(CAT) $(NEWDIR) $(TYPE) $(SOS) $(ROD) $(SIEVE) $(PRIMEGAP) $(MOUSE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(TFTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(SFM) $(SFMSPRT) $(GRAFIX) $(GFXDEMO) $(LINES) $(HGRTILE) $(HGRFONT) $(HGRSPRITE) $(HGRLIB) $(TILETEST) $(HGRTEST) $(GRLIB) $(DGRLIB) $(GRTEST) $(DGRTEST) $(HGRTEST) $(FILEIO_APL) $(CONIO_APL) $(JOYBUZZ) $(PORTIO) $(SPIPORT) $(SDFAT) $(FATCAT) $(FATGET) $(FATPUT) $(FATWDSK) $(FATRDSK) $(INT32) $(INT32TEST) $(SANE) $(FPSTR) $(FPU) $(SANITY) $(LZ4) $(LZ4CAT) $(RPNCALC) $(SNDSEQ) $(PLAYSEQ) $(CONIOTST)
-rm vmsrc/plvmzp.inc
c64: $(PLVMZP_C64) $(PLASM) $(PLVM) $(PLVMC64)
c64: $(PLVMZP_C64) $(PLASM) $(PLVM) $(PLVMC64)
-rm vmsrc/plvmzp.inc
all: apple c64
@ -142,11 +143,11 @@ $(PLASM): $(OBJS) $(INCS)
cc $(OBJS) -o $(PLASM)
$(PLASMAPLASM): toolsrc/plasm.pla toolsrc/lex.pla toolsrc/parse.pla toolsrc/codegen.pla toolsrc/codeseq.plh
./$(PLASM) -AMOW < toolsrc/plasm.pla > toolsrc/plasm.a
./$(PLASM) -AMOW toolsrc/plasm.pla
acme --setpc 4094 -o $(PLASMAPLASM) toolsrc/plasm.a
$(CODEOPT): toolsrc/codeopt.pla toolsrc/codeseq.plh
./$(PLASM) -AMOW < toolsrc/codeopt.pla > toolsrc/codeopt.a
./$(PLASM) -AMOW toolsrc/codeopt.pla
acme --setpc 4094 -o $(CODEOPT) toolsrc/codeopt.a
#
@ -176,25 +177,25 @@ $(PLVMC64): vmsrc/c64/plvmc64.s vmsrc/c64/cmd.a
acme -f cbm -o $(PLVMC64) -l vmsrc/c64/plvmc64.sym vmsrc/c64/plvmc64.s
vmsrc/apple/a1cmd.a: vmsrc/apple/a1cmd.pla $(PLASM)
./$(PLASM) -AOW < vmsrc/apple/a1cmd.pla > vmsrc/apple/a1cmd.a
./$(PLASM) -AOW vmsrc/apple/a1cmd.pla
$(PLVM01): vmsrc/apple/plvm01.s vmsrc/apple/a1cmd.a
acme -o $(PLVM01) -l vmsrc/apple/plvm01.sym vmsrc/apple/plvm01.s
$(CMD): vmsrc/apple/cmd.pla vmsrc/apple/cmdstub.s $(PLVM02) $(PLASM)
./$(PLASM) -AOW < vmsrc/apple/cmd.pla > vmsrc/apple/cmd.a
./$(PLASM) -AOW vmsrc/apple/cmd.pla
acme --setpc 8192 -o $(CMD) vmsrc/apple/cmdstub.s
$(CMDJIT): vmsrc/apple/cmdjit.pla vmsrc/apple/cmdjitstub.s $(PLVMJIT) $(PLASM)
./$(PLASM) -AOW < vmsrc/apple/cmdjit.pla > vmsrc/apple/cmdjit.a
./$(PLASM) -AOW vmsrc/apple/cmdjit.pla
acme --setpc 8192 -o $(CMDJIT) vmsrc/apple/cmdjitstub.s
$(SOSCMD): vmsrc/apple/soscmd.pla $(PLVM03) $(PLASM)
./$(PLASM) -AMOW < vmsrc/apple/soscmd.pla > vmsrc/apple/soscmd.a
./$(PLASM) -AMOW vmsrc/apple/soscmd.pla
acme --setpc 4094 -o $(SOSCMD) vmsrc/apple/soscmd.a
$(SOSCMDJIT): vmsrc/apple/soscmdjit.pla libsrc/jitcore.pla $(PLVMJIT03) $(PLASM)
./$(PLASM) -AMOW < vmsrc/apple/soscmdjit.pla > vmsrc/apple/soscmdjit.a
./$(PLASM) -AMOW vmsrc/apple/soscmdjit.pla
acme --setpc 4094 -o $(SOSCMDJIT) vmsrc/apple/soscmdjit.a
$(PLVM02): vmsrc/apple/plvm02.s
@ -207,13 +208,13 @@ $(PLVM802): vmsrc/apple/plvm802.s
acme -o $(PLVM802) -l vmsrc/apple/plvm802.sym vmsrc/apple/plvm802.s
vmsrc/apple/sossys.a: vmsrc/apple/sossys.pla $(PLASM)
./$(PLASM) -AOW < vmsrc/apple/sossys.pla > vmsrc/apple/sossys.a
./$(PLASM) -AOW vmsrc/apple/sossys.pla
$(PLVM03): vmsrc/apple/plvm03.s vmsrc/apple/sossys.a
acme -o $(PLVM03) -l vmsrc/apple/plvm03.sym vmsrc/apple/plvm03.s
vmsrc/apple/sossysjit.a: vmsrc/apple/sossysjit.pla $(PLASM)
./$(PLASM) -AOW < vmsrc/apple/sossysjit.pla > vmsrc/apple/sossysjit.a
./$(PLASM) -AOW vmsrc/apple/sossysjit.pla
$(PLVMJIT03): vmsrc/apple/plvmjit03.s vmsrc/apple/sossysjit.a
acme -o $(PLVMJIT03) -l vmsrc/apple/plvmjit03.sym vmsrc/apple/plvmjit03.s
@ -221,306 +222,309 @@ $(PLVMJIT03): vmsrc/apple/plvmjit03.s vmsrc/apple/sossysjit.a
# Sample code
#
test: samplesrc/test.pla samplesrc/testlib.pla $(PLVM) $(PLASM)
./$(PLASM) -AMOW < samplesrc/test.pla > samplesrc/test.a
./$(PLASM) -AMOW samplesrc/test.pla
acme --setpc 4094 -o $(TEST) samplesrc/test.a
./$(PLASM) -AMOW < samplesrc/testlib.pla > samplesrc/testlib.a
./$(PLASM) -AMOW samplesrc/testlib.pla
acme --setpc 4094 -o $(TESTLIB) samplesrc/testlib.a
./$(PLVM) TEST
$(ED): toolsrc/ed.pla $(PLVM02) $(PLASM) toolsrc/ed.pla
./$(PLASM) -AMOW < toolsrc/ed.pla > toolsrc/ed.a
./$(PLASM) -AMOW toolsrc/ed.pla
acme --setpc 4094 -o $(ED) toolsrc/ed.a
$(MATCHFILES): libsrc/apple/matchfiles.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/matchfiles.pla > libsrc/apple/matchfiles.a
./$(PLASM) -AMOW libsrc/apple/matchfiles.pla
acme --setpc 4094 -o $(MATCHFILES) libsrc/apple/matchfiles.a
$(ARGS): libsrc/args.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/args.pla > libsrc/args.a
./$(PLASM) -AMOW libsrc/args.pla
acme --setpc 4094 -o $(ARGS) libsrc/args.a
$(MEMMGR): libsrc/memmgr.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/memmgr.pla > libsrc/memmgr.a
./$(PLASM) -AMOW libsrc/memmgr.pla
acme --setpc 4094 -o $(MEMMGR) libsrc/memmgr.a
$(MEMTEST): samplesrc/memtest.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/memtest.pla > samplesrc/memtest.a
./$(PLASM) -AMOW samplesrc/memtest.pla
acme --setpc 4094 -o $(MEMTEST) samplesrc/memtest.a
$(FIBER): libsrc/fiber.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/fiber.pla > libsrc/fiber.a
./$(PLASM) -AMOW libsrc/fiber.pla
acme --setpc 4094 -o $(FIBER) libsrc/fiber.a
$(LINES): libsrc/lines.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/lines.pla > libsrc/lines.a
./$(PLASM) -AMOW libsrc/lines.pla
acme --setpc 4094 -o $(LINES) libsrc/lines.a
$(FIBERTEST): samplesrc/fibertest.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/fibertest.pla > samplesrc/fibertest.a
./$(PLASM) -AMOW samplesrc/fibertest.pla
acme --setpc 4094 -o $(FIBERTEST) samplesrc/fibertest.a
$(LONGJMP): libsrc/longjmp.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/longjmp.pla > libsrc/longjmp.a
./$(PLASM) -AMOW libsrc/longjmp.pla
acme --setpc 4094 -o $(LONGJMP) libsrc/longjmp.a
$(SFM): samplesrc/sfm.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/sfm.pla > samplesrc/sfm.a
./$(PLASM) -AMOW samplesrc/sfm.pla
acme --setpc 4094 -o $(SFM) samplesrc/sfm.a
$(SFMSPRT): samplesrc/sfmsprt.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/sfmsprt.pla > samplesrc/sfmsprt.a
./$(PLASM) -AMOW samplesrc/sfmsprt.pla
acme --setpc 4094 -o $(SFMSPRT) samplesrc/sfmsprt.a
$(ROGUE): samplesrc/rogue.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/rogue.pla > samplesrc/rogue.a
./$(PLASM) -AMOW samplesrc/rogue.pla
acme --setpc 4094 -o $(ROGUE) samplesrc/rogue.a
$(ROGUECOMBAT): samplesrc/rogue.combat.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/rogue.combat.pla > samplesrc/rogue.combat.a
./$(PLASM) -AMOW samplesrc/rogue.combat.pla
acme --setpc 4094 -o $(ROGUECOMBAT) samplesrc/rogue.combat.a
$(ROGUEMAP): samplesrc/rogue.map.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/rogue.map.pla > samplesrc/rogue.map.a
./$(PLASM) -AMOW samplesrc/rogue.map.pla
acme --setpc 4094 -o $(ROGUEMAP) samplesrc/rogue.map.a
hello: samplesrc/hello.pla $(PLVM) $(PLASM)
./$(PLASM) -AMOW < samplesrc/hello.pla > samplesrc/hello.a
./$(PLASM) -AMOW samplesrc/hello.pla
acme --setpc 4094 -o $(HELLO) samplesrc/hello.a
./$(PLVM) HELLO
$(CONIOTST): samplesrc/coniotst.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW samplesrc/coniotst.pla
acme --setpc 4094 -o $(CONIOTST) samplesrc/coniotst.a
$(ROD): samplesrc/rod.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/rod.pla > samplesrc/rod.a
./$(PLASM) -AMOW samplesrc/rod.pla
acme --setpc 4094 -o $(ROD) samplesrc/rod.a
$(SIEVE): samplesrc/sieve.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMW < samplesrc/sieve.pla > samplesrc/sieve.a
./$(PLASM) -AMW samplesrc/sieve.pla
acme --setpc 4094 -o $(SIEVE) samplesrc/sieve.a
$(PRIMEGAP): samplesrc/primegap.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMW < samplesrc/primegap.pla > samplesrc/primegap.a
./$(PLASM) -AMW samplesrc/primegap.pla
acme --setpc 4094 -o $(PRIMEGAP) samplesrc/primegap.a
$(INT32): libsrc/int32.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/int32.pla > libsrc/int32.a
./$(PLASM) -AMOW libsrc/int32.pla
acme --setpc 4094 -o $(INT32) libsrc/int32.a
$(INT32TEST): samplesrc/int32test.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/int32test.pla > samplesrc/int32test.a
./$(PLASM) -AMOW samplesrc/int32test.pla
acme --setpc 4094 -o $(INT32TEST) samplesrc/int32test.a
$(SANE): libsrc/sane.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/sane.pla > libsrc/sane.a
./$(PLASM) -AMOW libsrc/sane.pla
acme --setpc 4094 -o $(SANE) libsrc/sane.a
$(FPSTR): libsrc/fpstr.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/fpstr.pla > libsrc/fpstr.a
./$(PLASM) -AMOW libsrc/fpstr.pla
acme --setpc 4094 -o $(FPSTR) libsrc/fpstr.a
$(FPU): libsrc/fpu.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/fpu.pla > libsrc/fpu.a
./$(PLASM) -AMOW libsrc/fpu.pla
acme --setpc 4094 -o $(FPU) libsrc/fpu.a
$(SANITY): samplesrc/sanity.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/sanity.pla > samplesrc/sanity.a
./$(PLASM) -AMOW samplesrc/sanity.pla
acme --setpc 4094 -o $(SANITY) samplesrc/sanity.a
$(LZ4): libsrc/lz4.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/lz4.pla > libsrc/lz4.a
./$(PLASM) -AMOW libsrc/lz4.pla
acme --setpc 4094 -o $(LZ4) libsrc/lz4.a
$(LZ4CAT): samplesrc/lz4cat.pla inc/lz4.plh $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/lz4cat.pla > samplesrc/lz4cat.a
./$(PLASM) -AMOW samplesrc/lz4cat.pla
acme --setpc 4094 -o $(LZ4CAT) samplesrc/lz4cat.a
$(RPNCALC): samplesrc/rpncalc.pla libsrc/fpu.pla inc/fpu.plh libsrc/fpstr.pla inc/fpstr.plh inc/conio.plh $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/rpncalc.pla > samplesrc/rpncalc.a
./$(PLASM) -AMOW samplesrc/rpncalc.pla
acme --setpc 4094 -o $(RPNCALC) samplesrc/rpncalc.a
$(ETHERIP): libsrc/etherip.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/etherip.pla > libsrc/etherip.a
./$(PLASM) -AMOW libsrc/etherip.pla
acme --setpc 4094 -o $(ETHERIP) libsrc/etherip.a
$(INET): libsrc/inet.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/inet.pla > libsrc/inet.a
./$(PLASM) -AMOW libsrc/inet.pla
acme --setpc 4094 -o $(INET) libsrc/inet.a
$(DHCP): libsrc/dhcp.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/dhcp.pla > libsrc/dhcp.a
./$(PLASM) -AMOW libsrc/dhcp.pla
acme --setpc 4094 -o $(DHCP) libsrc/dhcp.a
$(HTTPD): samplesrc/httpd.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/httpd.pla > samplesrc/httpd.a
./$(PLASM) -AMOW samplesrc/httpd.pla
acme --setpc 4094 -o $(HTTPD) samplesrc/httpd.a
$(TFTPD): utilsrc/tftpd.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < utilsrc/tftpd.pla > utilsrc/tftpd.a
./$(PLASM) -AMOW utilsrc/tftpd.pla
acme --setpc 4094 -o $(TFTPD) utilsrc/tftpd.a
$(MOUSE): libsrc/apple/mouse.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/mouse.pla > libsrc/apple/mouse.a
./$(PLASM) -AMOW libsrc/apple/mouse.pla
acme --setpc 4094 -o $(MOUSE) libsrc/apple/mouse.a
$(UTHERNET): libsrc/apple/uthernet.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/uthernet.pla > libsrc/apple/uthernet.a
./$(PLASM) -AMOW libsrc/apple/uthernet.pla
acme --setpc 4094 -o $(UTHERNET) libsrc/apple/uthernet.a
$(UTHERNET2): libsrc/apple/uthernet2.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/uthernet2.pla > libsrc/apple/uthernet2.a
./$(PLASM) -AMOW libsrc/apple/uthernet2.pla
acme --setpc 4094 -o $(UTHERNET2) libsrc/apple/uthernet2.a
$(FILEIO_APL): libsrc/apple/fileio.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/fileio.pla > libsrc/apple/fileio.a
./$(PLASM) -AMOW libsrc/apple/fileio.pla
acme --setpc 4094 -o $(FILEIO_APL) libsrc/apple/fileio.a
$(CONIO_APL): libsrc/apple/conio.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/conio.pla > libsrc/apple/conio.a
./$(PLASM) -AMOW libsrc/apple/conio.pla
acme --setpc 4094 -o $(CONIO_APL) libsrc/apple/conio.a
$(FILEIO_C64): libsrc/c64/fileio.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/c64/fileio.pla > libsrc/c64/fileio.a
./$(PLASM) -AMOW libsrc/c64/fileio.pla
acme --setpc 4094 -o $(FILEIO_C64) libsrc/c64/fileio.a
$(CONIO_C64): libsrc/c64/conio.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/c64/conio.pla > libsrc/c64/conio.a
./$(PLASM) -AMOW libsrc/c64/conio.pla
acme --setpc 4094 -o $(CONIO_C64) libsrc/c64/conio.a
$(SNDSEQ): libsrc/apple/sndseq.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/sndseq.pla > libsrc/apple/sndseq.a
./$(PLASM) -AMOW libsrc/apple/sndseq.pla
acme --setpc 4094 -o $(SNDSEQ) libsrc/apple/sndseq.a
$(PLAYSEQ): samplesrc/playseq.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/playseq.pla > samplesrc/playseq.a
./$(PLASM) -AMOW samplesrc/playseq.pla
acme --setpc 4094 -o $(PLAYSEQ) samplesrc/playseq.a
$(GRAFIX): libsrc/apple/grafix.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/grafix.pla > libsrc/apple/grafix.a
./$(PLASM) -AMOW libsrc/apple/grafix.pla
acme --setpc 4094 -o $(GRAFIX) libsrc/apple/grafix.a
$(GFXDEMO): samplesrc/gfxdemo.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/gfxdemo.pla > samplesrc/gfxdemo.a
./$(PLASM) -AMOW samplesrc/gfxdemo.pla
acme --setpc 4094 -o $(GFXDEMO) samplesrc/gfxdemo.a
$(FATCAT): samplesrc/fatcat.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/fatcat.pla > samplesrc/fatcat.a
./$(PLASM) -AMOW samplesrc/fatcat.pla
acme --setpc 4094 -o $(FATCAT) samplesrc/fatcat.a
$(FATGET): samplesrc/fatget.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/fatget.pla > samplesrc/fatget.a
./$(PLASM) -AMOW samplesrc/fatget.pla
acme --setpc 4094 -o $(FATGET) samplesrc/fatget.a
$(FATPUT): samplesrc/fatput.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/fatput.pla > samplesrc/fatput.a
./$(PLASM) -AMOW samplesrc/fatput.pla
acme --setpc 4094 -o $(FATPUT) samplesrc/fatput.a
$(FATWDSK): samplesrc/fatwritedsk.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/fatwritedsk.pla > samplesrc/fatwritedsk.a
./$(PLASM) -AMOW samplesrc/fatwritedsk.pla
acme --setpc 4094 -o $(FATWDSK) samplesrc/fatwritedsk.a
$(FATRDSK): samplesrc/fatreaddsk.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < samplesrc/fatreaddsk.pla > samplesrc/fatreaddsk.a
./$(PLASM) -AMOW samplesrc/fatreaddsk.pla
acme --setpc 4094 -o $(FATRDSK) samplesrc/fatreaddsk.a
$(SDFAT): libsrc/apple/sdfat.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/sdfat.pla > libsrc/apple/sdfat.a
./$(PLASM) -AMOW libsrc/apple/sdfat.pla
acme --setpc 4094 -o $(SDFAT) libsrc/apple/sdfat.a
$(SPIPORT): libsrc/apple/spiport.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/spiport.pla > libsrc/apple/spiport.a
./$(PLASM) -AMOW libsrc/apple/spiport.pla
acme --setpc 4094 -o $(SPIPORT) libsrc/apple/spiport.a
$(JOYBUZZ): libsrc/apple/joybuzz.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/joybuzz.pla > libsrc/apple/joybuzz.a
./$(PLASM) -AMOW libsrc/apple/joybuzz.pla
acme --setpc 4094 -o $(JOYBUZZ) libsrc/apple/joybuzz.a
$(PORTIO): libsrc/apple/portio.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/portio.pla > libsrc/apple/portio.a
./$(PLASM) -AMOW libsrc/apple/portio.pla
acme --setpc 4094 -o $(PORTIO) libsrc/apple/portio.a
$(HGRLIB): libsrc/apple/hgrlib.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/hgrlib.pla > libsrc/apple/hgrlib.a
./$(PLASM) -AMOW libsrc/apple/hgrlib.pla
acme --setpc 4094 -o $(HGRLIB) libsrc/apple/hgrlib.a
$(GRLIB): libsrc/apple/grlib.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/grlib.pla > libsrc/apple/grlib.a
./$(PLASM) -AMOW libsrc/apple/grlib.pla
acme --setpc 4094 -o $(GRLIB) libsrc/apple/grlib.a
$(DGRLIB): libsrc/apple/dgrlib.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/dgrlib.pla > libsrc/apple/dgrlib.a
./$(PLASM) -AMOW libsrc/apple/dgrlib.pla
acme --setpc 4094 -o $(DGRLIB) libsrc/apple/dgrlib.a
$(TILETEST): samplesrc/tiletest.pla $(PLASM)
./$(PLASM) -AMOW < samplesrc/tiletest.pla > samplesrc/tiletest.a
./$(PLASM) -AMOW samplesrc/tiletest.pla
acme --setpc 4094 -o $(TILETEST) samplesrc/tiletest.a
$(HGRTILE): libsrc/apple/hgrtile.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/hgrtile.pla > libsrc/apple/hgrtile.a
./$(PLASM) -AMOW libsrc/apple/hgrtile.pla
acme --setpc 4094 -o $(HGRTILE) libsrc/apple/hgrtile.a
$(HGRFONT): libsrc/apple/hgrfont.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/hgrfont.pla > libsrc/apple/hgrfont.a
./$(PLASM) -AMOW libsrc/apple/hgrfont.pla
acme --setpc 4094 -o $(HGRFONT) libsrc/apple/hgrfont.a
$(HGRSPRITE): libsrc/apple/hgrsprite.pla $(PLVM02) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/hgrsprite.pla > libsrc/apple/hgrsprite.a
./$(PLASM) -AMOW libsrc/apple/hgrsprite.pla
acme --setpc 4094 -o $(HGRSPRITE) libsrc/apple/hgrsprite.a
$(HGRTEST): samplesrc/hgrtest.pla $(HGRLIB) $(PLASM)
./$(PLASM) -AMOW < samplesrc/hgrtest.pla > samplesrc/hgrtest.a
./$(PLASM) -AMOW samplesrc/hgrtest.pla
acme --setpc 4094 -o $(HGRTEST) samplesrc/hgrtest.a
$(GRTEST): samplesrc/grtest.pla $(GRLIB) $(PLASM)
./$(PLASM) -AMOW < samplesrc/grtest.pla > samplesrc/grtest.a
./$(PLASM) -AMOW samplesrc/grtest.pla
acme --setpc 4094 -o $(GRTEST) samplesrc/grtest.a
$(DGRTEST): samplesrc/dgrtest.pla $(DGRLIB) $(PLASM)
./$(PLASM) -AMOW < samplesrc/dgrtest.pla > samplesrc/dgrtest.a
./$(PLASM) -AMOW samplesrc/dgrtest.pla
acme --setpc 4094 -o $(DGRTEST) samplesrc/dgrtest.a
$(MON): utilsrc/apple/mon.pla $(PLASM)
./$(PLASM) -AMOW < utilsrc/apple/mon.pla > utilsrc/apple/mon.a
./$(PLASM) -AMOW utilsrc/apple/mon.pla
acme --setpc 4094 -o $(MON) utilsrc/apple/mon.a
$(COPY): utilsrc/apple/copy.pla $(PLASM)
./$(PLASM) -AMOW < utilsrc/apple/copy.pla > utilsrc/apple/copy.a
$(COPY): utilsrc/apple/copy.pla $(MATCHFILES) $(PLASM)
./$(PLASM) -AMOW utilsrc/apple/copy.pla
acme --setpc 4094 -o $(COPY) utilsrc/apple/copy.a
$(DEL): utilsrc/apple/del.pla $(PLASM)
./$(PLASM) -AMOW < utilsrc/apple/del.pla > utilsrc/apple/del.a
$(DEL): utilsrc/apple/del.pla $(MATCHFILES) $(PLASM)
./$(PLASM) -AMOW utilsrc/apple/del.pla
acme --setpc 4094 -o $(DEL) utilsrc/apple/del.a
$(REN): utilsrc/apple/ren.pla $(PLASM)
./$(PLASM) -AMOW < utilsrc/apple/ren.pla > utilsrc/apple/ren.a
./$(PLASM) -AMOW utilsrc/apple/ren.pla
acme --setpc 4094 -o $(REN) utilsrc/apple/ren.a
$(CAT): utilsrc/apple/cat.pla $(PLASM)
./$(PLASM) -AMOW < utilsrc/apple/cat.pla > utilsrc/apple/cat.a
$(CAT): utilsrc/apple/cat.pla $(MATCHFILES) $(PLASM)
./$(PLASM) -AMOW utilsrc/apple/cat.pla
acme --setpc 4094 -o $(CAT) utilsrc/apple/cat.a
$(NEWDIR): utilsrc/apple/newdir.pla $(PLASM)
./$(PLASM) -AMOW < utilsrc/apple/newdir.pla > utilsrc/apple/newdir.a
./$(PLASM) -AMOW utilsrc/apple/newdir.pla
acme --setpc 4094 -o $(NEWDIR) utilsrc/apple/newdir.a
$(TYPE): utilsrc/apple/type.pla $(PLASM)
./$(PLASM) -AMOW < utilsrc/apple/type.pla > utilsrc/apple/type.a
./$(PLASM) -AMOW utilsrc/apple/type.pla
acme --setpc 4094 -o $(TYPE) utilsrc/apple/type.a
$(SOS): utilsrc/apple/sos.pla $(PLVM03) $(PLASM)
./$(PLASM) -AMOW < utilsrc/apple/sos.pla > utilsrc/apple/sos.a
./$(PLASM) -AMOW utilsrc/apple/sos.pla
acme --setpc 4094 -o $(SOS) utilsrc/apple/sos.a
$(ZIPCHIP): utilsrc/apple/zipchip.pla $(PLASM)
./$(PLASM) -AMOW < utilsrc/apple/zipchip.pla > utilsrc/apple/zipchip.a
./$(PLASM) -AMOW utilsrc/apple/zipchip.pla
acme --setpc 4094 -o $(ZIPCHIP) utilsrc/apple/zipchip.a
$(JIT): libsrc/apple/jit.pla libsrc/jitcore.pla $(PLVMJIT) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/jit.pla > libsrc/apple/jit.a
./$(PLASM) -AMOW libsrc/apple/jit.pla
acme --setpc 4094 -o $(JIT) libsrc/apple/jit.a
$(JIT16): libsrc/apple/jit16.pla libsrc/jit16core.pla $(PLVMJIT) $(PLASM)
./$(PLASM) -AMOW < libsrc/apple/jit16.pla > libsrc/apple/jit16.a
./$(PLASM) -AMOW libsrc/apple/jit16.pla
acme --setpc 4094 -o $(JIT16) libsrc/apple/jit16.a
$(JITUNE): utilsrc/apple/jitune.pla $(PLVMJIT) $(PLASM)
./$(PLASM) -AMOW < utilsrc/apple/jitune.pla > utilsrc/apple/jitune.a
./$(PLASM) -AMOW utilsrc/apple/jitune.pla
acme --setpc 4094 -o $(JITUNE) utilsrc/apple/jitune.a

View File

@ -125,11 +125,12 @@ cp ../sysfiles/ELEMS.CODE#060000 prodos/fpsos/sys/ELEMS.CODE.BIN
rm -rf prodos/demos
mkdir prodos/demos
cp rel/INT32TEST#FE1000 prodos/demos/INT32TEST.REL
cp rel/apple/ROD#FE1000 prodos/demos/ROD.REL
cp rel/RPNCALC#FE1000 prodos/demos/RPNCALC.REL
cp rel/LZ4CAT#FE1000 prodos/demos/LZ4CAT.REL
cp rel/PRIMEGAP#FE1000 prodos/demos/PRIMEGAP.REL
cp rel/INT32TEST#FE1000 prodos/demos/INT32TEST.REL
cp rel/apple/CONIOTST#FE1000 prodos/demos/CONIOTST.REL
cp rel/apple/ROD#FE1000 prodos/demos/ROD.REL
cp rel/RPNCALC#FE1000 prodos/demos/RPNCALC.REL
cp rel/LZ4CAT#FE1000 prodos/demos/LZ4CAT.REL
cp rel/PRIMEGAP#FE1000 prodos/demos/PRIMEGAP.REL
mkdir prodos/demos/rogue
cp rel/ROGUE#FE1000 prodos/demos/rogue/ROGUE.REL
@ -178,6 +179,7 @@ cp rel/CODEOPT#FE1000 prodos/bld/CODEOPT.REL
mkdir prodos/bld/samples
cp samplesrc/hello.pla prodos/bld/samples/HELLO.PLA.TXT
cp samplesrc/int32test.pla prodos/bld/samples/INT32TEST.PLA.TXT
cp samplesrc/coniotst.pla prodos/bld/samples/CONIOTST.PLA.TXT
cp samplesrc/grtest.pla prodos/bld/samples/GRTEST.PLA.TXT
cp samplesrc/dgrtest.pla prodos/bld/samples/DGRTEST.PLA.TXT
cp samplesrc/hgrtest.pla prodos/bld/samples/HGRTEST.PLA.TXT

View File

@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/python
import sys
#from mido import MidiFile

View File

@ -0,0 +1,31 @@
// text screen
include "inc/cmdsys.plh"
include "inc/conio.plh"
const SCR_PTR = $0400
const SCR_SIZE = 1024
byte[SCR_SIZE] ScrSave
byte I
word Name
// save text screen
memcpy(@ScrSave, SCR_PTR, SCR_SIZE)
conio:home()
for I=0 to 23
conio:gotoxy(I,I)
putc('A'+I)
putc(' ')
puti(I)
next
conio:gotoxy(10, 5)
puts("What is your name")
Name = gets('?'|$80) // $BF
conio:gotoxy(12, 7)
puts("Nice to meet you, ")
puts(Name)
conio:gotoxy(16, 10)
puts("Press any key ...")
getc()
conio:gotoxy(0, 5)
memcpy(SCR_PTR, @ScrSave, SCR_SIZE)
done

View File

@ -41,9 +41,9 @@ static t_opseq *pending_seq = 0;
#define FIXUP_WORD 0x80
int id_match(char *name, int len, char *id)
{
if (len > ID_LEN) len = ID_LEN;
if (len == id[0])
{
if (len > 16) len = 16;
while (len--)
{
if (toupper(name[len]) != id[1 + len])
@ -83,7 +83,7 @@ int idglobal_lookup(char *name, int len)
}
int idconst_add(char *name, int len, int value)
{
char c = name[len];
char c;
if (consts > 1024)
{
printf("Constant count overflow\n");
@ -99,11 +99,12 @@ int idconst_add(char *name, int len, int value)
parse_error("global label already defined\n");
return (0);
}
if (len > ID_LEN) len = ID_LEN;
c = name[len];
name[len] = '\0';
emit_idconst(name, value);
name[len] = c;
idconst_name[consts][0] = len;
if (len > ID_LEN) len = ID_LEN;
while (len--)
idconst_name[consts][1 + len] = toupper(name[len]);
idconst_value[consts] = value;
@ -112,7 +113,7 @@ int idconst_add(char *name, int len, int value)
}
int idlocal_add(char *name, int len, int type, int size)
{
char c = name[len];
char c;
if (localsize > 255)
{
printf("Local variable size overflow\n");
@ -128,11 +129,12 @@ int idlocal_add(char *name, int len, int type, int size)
parse_error("local label already defined\n");
return (0);
}
if (len > ID_LEN) len = ID_LEN;
c = name[len];
name[len] = '\0';
emit_idlocal(name, localsize);
name[len] = c;
idlocal_name[locals][0] = len;
if (len > ID_LEN) len = ID_LEN;
while (len--)
idlocal_name[locals][1 + len] = toupper(name[len]);
idlocal_type[locals] = type | LOCAL_TYPE;
@ -143,7 +145,6 @@ int idlocal_add(char *name, int len, int type, int size)
}
int idglobal_add(char *name, int len, int type, int size)
{
char c = name[len];
if (globals > 1024)
{
printf("Global variable count overflow\n");
@ -159,10 +160,8 @@ int idglobal_add(char *name, int len, int type, int size)
parse_error("global label already defined\n");
return (0);
}
name[len] = '\0';
name[len] = c;
idglobal_name[globals][0] = len;
if (len > ID_LEN) len = ID_LEN;
idglobal_name[globals][0] = len;
while (len--)
idglobal_name[globals][1 + len] = toupper(name[len]);
idglobal_type[globals] = type;
@ -174,7 +173,7 @@ int idglobal_add(char *name, int len, int type, int size)
}
else
{
printf("\t\t\t\t\t; %s -> X%03d\n", &idglobal_name[globals][1], externs);
fprintf(outputfile, "\t\t\t\t\t; %s -> X%03d\n", &idglobal_name[globals][1], externs);
idglobal_tag[globals++] = externs++;
}
return (1);
@ -213,14 +212,14 @@ int idfunc_add(char *name, int len, int type, int tag)
printf("Global variable count overflow\n");
return (0);
}
idglobal_name[globals][0] = len;
if (len > ID_LEN) len = ID_LEN;
idglobal_name[globals][0] = len;
while (len--)
idglobal_name[globals][1 + len] = toupper(name[len]);
idglobal_type[globals] = type;
idglobal_tag[globals++] = tag;
if (type & EXTERN_TYPE)
printf("\t\t\t\t\t; %s -> X%03d\n", &idglobal_name[globals - 1][1], tag);
fprintf(outputfile, "\t\t\t\t\t; %s -> X%03d\n", &idglobal_name[globals - 1][1], tag);
return (1);
}
int idfunc_set(char *name, int len, int type, int tag)
@ -344,11 +343,11 @@ void emit_dci(char *str, int len)
{
if (len--)
{
printf("\t; DCI STRING: %s\n", supper(str));
printf("\t%s\t$%02X", DB, toupper(*str++) | (len ? 0x80 : 0x00));
fprintf(outputfile, "\t; DCI STRING: %s\n", supper(str));
fprintf(outputfile, "\t%s\t$%02X", DB, toupper(*str++) | (len ? 0x80 : 0x00));
while (len--)
printf(",$%02X", toupper(*str++) | (len ? 0x80 : 0x00));
printf("\n");
fprintf(outputfile, ",$%02X", toupper(*str++) | (len ? 0x80 : 0x00));
fprintf(outputfile, "\n");
}
}
void emit_flags(int flags)
@ -366,22 +365,22 @@ void emit_header(void)
int i;
if (outflags & ACME)
printf("; ACME COMPATIBLE OUTPUT\n");
fprintf(outputfile, "; ACME COMPATIBLE OUTPUT\n");
else
printf("; CA65 COMPATIBLE OUTPUT\n");
fprintf(outputfile, "; CA65 COMPATIBLE OUTPUT\n");
if (outflags & MODULE)
{
printf("\t%s\t_SEGEND-_SEGBEGIN\t; LENGTH OF HEADER + CODE/DATA + BYTECODE SEGMENT\n", DW);
printf("_SEGBEGIN%c\n", LBL);
printf("\t%s\t$6502\t\t\t; MAGIC #\n", DW);
printf("\t%s\t_SYSFLAGS\t\t\t; SYSTEM FLAGS\n", DW);
printf("\t%s\t_SUBSEG\t\t\t; BYTECODE SUB-SEGMENT\n", DW);
printf("\t%s\t_DEFCNT\t\t\t; BYTECODE DEF COUNT\n", DW);
printf("\t%s\t_INIT\t\t\t; MODULE INITIALIZATION ROUTINE\n", DW);
fprintf(outputfile, "\t%s\t_SEGEND-_SEGBEGIN\t; LENGTH OF HEADER + CODE/DATA + BYTECODE SEGMENT\n", DW);
fprintf(outputfile, "_SEGBEGIN%c\n", LBL);
fprintf(outputfile, "\t%s\t$6502\t\t\t; MAGIC #\n", DW);
fprintf(outputfile, "\t%s\t_SYSFLAGS\t\t\t; SYSTEM FLAGS\n", DW);
fprintf(outputfile, "\t%s\t_SUBSEG\t\t\t; BYTECODE SUB-SEGMENT\n", DW);
fprintf(outputfile, "\t%s\t_DEFCNT\t\t\t; BYTECODE DEF COUNT\n", DW);
fprintf(outputfile, "\t%s\t_INIT\t\t\t; MODULE INITIALIZATION ROUTINE\n", DW);
}
else
{
printf("\tJMP\t_INIT\t\t\t; MODULE INITIALIZATION ROUTINE\n");
fprintf(outputfile, "\tJMP\t_INIT\t\t\t; MODULE INITIALIZATION ROUTINE\n");
}
/*
* Init free op sequence table
@ -394,7 +393,7 @@ void emit_rld(void)
{
int i, j;
printf(";\n; RE-LOCATEABLE DICTIONARY\n;\n");
fprintf(outputfile, ";\n; RE-LOCATEABLE DICTIONARY\n;\n");
/*
* First emit the bytecode definition entrypoint information.
*/
@ -410,9 +409,9 @@ void emit_rld(void)
j = outflags & INIT ? defs - 1 : defs;
for (i = 0; i < j; i++)
{
printf("\t%s\t$02\t\t\t; CODE TABLE FIXUP\n", DB);
printf("\t%s\t_C%03d\t\t\n", DW, i);
printf("\t%s\t$00\n", DB);
fprintf(outputfile, "\t%s\t$02\t\t\t; CODE TABLE FIXUP\n", DB);
fprintf(outputfile, "\t%s\t_C%03d\t\t\n", DW, i);
fprintf(outputfile, "\t%s\t$00\n", DB);
}
/*
* Now emit the fixup table.
@ -421,53 +420,53 @@ void emit_rld(void)
{
if (fixup_type[i] & EXTERN_TYPE)
{
printf("\t%s\t$%02X\t\t\t; EXTERNAL FIXUP\n", DB, 0x11 + fixup_size[i] & 0xFF);
printf("\t%s\t_F%03d-_SEGBEGIN\t\t\n", DW, i);
printf("\t%s\t%d\t\t\t; ESD INDEX\n", DB, fixup_tag[i]);
fprintf(outputfile, "\t%s\t$%02X\t\t\t; EXTERNAL FIXUP\n", DB, 0x11 + fixup_size[i] & 0xFF);
fprintf(outputfile, "\t%s\t_F%03d-_SEGBEGIN\t\t\n", DW, i);
fprintf(outputfile, "\t%s\t%d\t\t\t; ESD INDEX\n", DB, fixup_tag[i]);
}
else
{
printf("\t%s\t$%02X\t\t\t; INTERNAL FIXUP\n", DB, 0x01 + fixup_size[i] & 0xFF);
printf("\t%s\t_F%03d-_SEGBEGIN\t\t\n", DW, i);
printf("\t%s\t$00\n", DB);
fprintf(outputfile, "\t%s\t$%02X\t\t\t; INTERNAL FIXUP\n", DB, 0x01 + fixup_size[i] & 0xFF);
fprintf(outputfile, "\t%s\t_F%03d-_SEGBEGIN\t\t\n", DW, i);
fprintf(outputfile, "\t%s\t$00\n", DB);
}
}
printf("\t%s\t$00\t\t\t; END OF RLD\n", DB);
fprintf(outputfile, "\t%s\t$00\t\t\t; END OF RLD\n", DB);
}
void emit_esd(void)
{
int i;
printf(";\n; EXTERNAL/ENTRY SYMBOL DICTIONARY\n;\n");
fprintf(outputfile, ";\n; EXTERNAL/ENTRY SYMBOL DICTIONARY\n;\n");
for (i = 0; i < globals; i++)
{
if (idglobal_type[i] & ACCESSED_TYPE) // Only refer to accessed externals
{
emit_dci(&idglobal_name[i][1], idglobal_name[i][0]);
printf("\t%s\t$10\t\t\t; EXTERNAL SYMBOL FLAG\n", DB);
printf("\t%s\t%d\t\t\t; ESD INDEX\n", DW, idglobal_tag[i]);
fprintf(outputfile, "\t%s\t$10\t\t\t; EXTERNAL SYMBOL FLAG\n", DB);
fprintf(outputfile, "\t%s\t%d\t\t\t; ESD INDEX\n", DW, idglobal_tag[i]);
}
else if (idglobal_type[i] & EXPORT_TYPE)
{
emit_dci(&idglobal_name[i][1], idglobal_name[i][0]);
printf("\t%s\t$08\t\t\t; ENTRY SYMBOL FLAG\n", DB);
printf("\t%s\t%s\t\t\n", DW, tag_string(idglobal_tag[i], idglobal_type[i]));
fprintf(outputfile, "\t%s\t$08\t\t\t; ENTRY SYMBOL FLAG\n", DB);
fprintf(outputfile, "\t%s\t%s\t\t\n", DW, tag_string(idglobal_tag[i], idglobal_type[i]));
}
}
printf("\t%s\t$00\t\t\t; END OF ESD\n", DB);
fprintf(outputfile, "\t%s\t$00\t\t\t; END OF ESD\n", DB);
}
void emit_trailer(void)
{
if (!(outflags & BYTECODE_SEG))
emit_bytecode_seg();
if (!(outflags & INIT))
printf("_INIT\t=\t0\n");
fprintf(outputfile, "_INIT\t=\t0\n");
if (!(outflags & SYSFLAGS))
printf("_SYSFLAGS\t=\t0\n");
fprintf(outputfile, "_SYSFLAGS\t=\t0\n");
if (outflags & MODULE)
{
printf("_DEFCNT\t=\t%d\n", defs);
printf("_SEGEND%c\n", LBL);
fprintf(outputfile, "_DEFCNT\t=\t%d\n", defs);
fprintf(outputfile, "_SEGEND%c\n", LBL);
emit_rld();
emit_esd();
}
@ -482,12 +481,12 @@ void emit_moddep(char *name, int len)
idglobal_add(name, len, EXTERN_TYPE | WORD_TYPE, 2); // Add to symbol table
}
else
printf("\t%s\t$00\t\t\t; END OF MODULE DEPENDENCIES\n", DB);
fprintf(outputfile, "\t%s\t$00\t\t\t; END OF MODULE DEPENDENCIES\n", DB);
}
}
void emit_sysflags(int val)
{
printf("_SYSFLAGS\t=\t$%04X\t\t; SYSTEM FLAGS\n", val);
fprintf(outputfile, "_SYSFLAGS\t=\t$%04X\t\t; SYSTEM FLAGS\n", val);
outflags |= SYSFLAGS;
}
void emit_bytecode_seg(void)
@ -495,57 +494,57 @@ void emit_bytecode_seg(void)
if ((outflags & MODULE) && !(outflags & BYTECODE_SEG))
{
if (lastglobalsize == 0) // Pad a byte if last label is at end of data segment
printf("\t%s\t$00\t\t\t; PAD BYTE\n", DB);
printf("_SUBSEG%c\t\t\t\t; BYTECODE STARTS\n", LBL);
fprintf(outputfile, "\t%s\t$00\t\t\t; PAD BYTE\n", DB);
fprintf(outputfile, "_SUBSEG%c\t\t\t\t; BYTECODE STARTS\n", LBL);
}
outflags |= BYTECODE_SEG;
}
void emit_comment(char *s)
{
printf("\t\t\t\t\t; %s\n", s);
fprintf(outputfile, "\t\t\t\t\t; %s\n", s);
}
void emit_asm(char *s)
{
printf("%s\n", s);
fprintf(outputfile, "%s\n", s);
}
void emit_idlocal(char *name, int value)
{
printf("\t\t\t\t\t; %s -> [%d]\n", name, value);
fprintf(outputfile, "\t\t\t\t\t; %s -> [%d]\n", name, value);
}
void emit_idglobal(int tag, int size, char *name)
{
lastglobalsize = size;
if (size == 0)
printf("_D%03d%c\t\t\t\t\t; %s\n", tag, LBL, name);
fprintf(outputfile, "_D%03d%c\t\t\t\t\t; %s\n", tag, LBL, name);
else
printf("_D%03d%c\t%s\t%d\t\t\t; %s\n", tag, LBL, DS, size, name);
fprintf(outputfile, "_D%03d%c\t%s\t%d\t\t\t; %s\n", tag, LBL, DS, size, name);
}
void emit_idfunc(int tag, int type, char *name, int is_bytecode)
{
if (name)
printf("%s%c\t\t\t\t\t; %s()\n", tag_string(tag, type), LBL, name);
fprintf(outputfile, "%s%c\t\t\t\t\t; %s()\n", tag_string(tag, type), LBL, name);
if (!(outflags & MODULE))
{
//printf("%s%c\n", name, LBL);
//fprintf(outputfile, "%s%c\n", name, LBL);
if (is_bytecode)
printf("\tJSR\tINTERP\n");
fprintf(outputfile, "\tJSR\tINTERP\n");
}
}
void emit_lambdafunc(int tag, char *name, int cparams, t_opseq *lambda_seq)
{
emit_idfunc(tag, DEF_TYPE, name, 1);
if (cparams)
printf("\t%s\t$58,$%02X,$%02X\t\t; ENTER\t%d,%d\n", DB, cparams*2, cparams, cparams*2, cparams);
fprintf(outputfile, "\t%s\t$58,$%02X,$%02X\t\t; ENTER\t%d,%d\n", DB, cparams*2, cparams, cparams*2, cparams);
emit_seq(lambda_seq);
emit_pending_seq();
if (cparams)
printf("\t%s\t$5A,$%02X\t\t\t; LEAVE\t%d\n", DB, cparams*2, cparams*2);
fprintf(outputfile, "\t%s\t$5A,$%02X\t\t\t; LEAVE\t%d\n", DB, cparams*2, cparams*2);
else
printf("\t%s\t$5C\t\t\t; RET\n", DB);
fprintf(outputfile, "\t%s\t$5C\t\t\t; RET\n", DB);
}
void emit_idconst(char *name, int value)
{
printf("\t\t\t\t\t; %s = %d\n", name, value);
fprintf(outputfile, "\t\t\t\t\t; %s = %d\n", name, value);
}
int emit_data(int vartype, int consttype, long constval, int constsize)
{
@ -554,25 +553,25 @@ int emit_data(int vartype, int consttype, long constval, int constsize)
if (consttype == 0)
{
datasize = constsize;
printf("\t%s\t$%02X\n", DS, constsize);
fprintf(outputfile, "\t%s\t$%02X\n", DS, constsize);
}
else if (consttype & STRING_TYPE)
{
str = (unsigned char *)constval;
constsize = *str++;
datasize = constsize + 1;
printf("\t%s\t$%02X\n", DB, constsize);
fprintf(outputfile, "\t%s\t$%02X\n", DB, constsize);
while (constsize-- > 0)
{
printf("\t%s\t$%02X", DB, *str++);
fprintf(outputfile, "\t%s\t$%02X", DB, *str++);
for (i = 0; i < 7; i++)
{
if (constsize-- > 0)
printf(",$%02X", *str++);
fprintf(outputfile, ",$%02X", *str++);
else
break;
}
printf("\n");
fprintf(outputfile, "\n");
}
}
else if (consttype & ADDR_TYPE)
@ -582,18 +581,18 @@ int emit_data(int vartype, int consttype, long constval, int constsize)
int fixup = fixup_new(constval, consttype, FIXUP_WORD);
datasize = 2;
if (consttype & EXTERN_TYPE)
printf("_F%03d%c\t%s\t0\t\t\t; %s\n", fixup, LBL, DW, tag_string(constval, consttype));
fprintf(outputfile, "_F%03d%c\t%s\t0\t\t\t; %s\n", fixup, LBL, DW, tag_string(constval, consttype));
else
printf("_F%03d%c\t%s\t%s\n", fixup, LBL, DW, tag_string(constval, consttype));
fprintf(outputfile, "_F%03d%c\t%s\t%s\n", fixup, LBL, DW, tag_string(constval, consttype));
}
else
{
int fixup = fixup_new(constval, consttype, FIXUP_BYTE);
datasize = 1;
if (consttype & EXTERN_TYPE)
printf("_F%03d%c\t%s\t0\t\t\t; %s\n", fixup, LBL, DB, tag_string(constval, consttype));
fprintf(outputfile, "_F%03d%c\t%s\t0\t\t\t; %s\n", fixup, LBL, DB, tag_string(constval, consttype));
else
printf("_F%03d%c\t%s\t%s\n", fixup, LBL, DB, tag_string(constval, consttype));
fprintf(outputfile, "_F%03d%c\t%s\t%s\n", fixup, LBL, DB, tag_string(constval, consttype));
}
}
else
@ -601,12 +600,12 @@ int emit_data(int vartype, int consttype, long constval, int constsize)
if (vartype & WORD_TYPE)
{
datasize = 2;
printf("\t%s\t$%04lX\n", DW, constval & 0xFFFF);
fprintf(outputfile, "\t%s\t$%04lX\n", DW, constval & 0xFFFF);
}
else
{
datasize = 1;
printf("\t%s\t$%02lX\n", DB, constval & 0xFF);
fprintf(outputfile, "\t%s\t$%02lX\n", DB, constval & 0xFF);
}
}
return (datasize);
@ -614,78 +613,78 @@ int emit_data(int vartype, int consttype, long constval, int constsize)
void emit_codetag(int tag)
{
emit_pending_seq();
printf("_B%03d%c\n", tag, LBL);
fprintf(outputfile, "_B%03d%c\n", tag, LBL);
}
void emit_const(int cval)
{
emit_pending_seq();
if ((cval & 0xFFFF) == 0xFFFF)
printf("\t%s\t$20\t\t\t; MINUS ONE\n", DB);
fprintf(outputfile, "\t%s\t$20\t\t\t; MINUS ONE\n", DB);
else if ((cval & 0xFFF0) == 0x0000)
printf("\t%s\t$%02X\t\t\t; CN\t%d\n", DB, cval*2, cval);
fprintf(outputfile, "\t%s\t$%02X\t\t\t; CN\t%d\n", DB, cval*2, cval);
else if ((cval & 0xFF00) == 0x0000)
printf("\t%s\t$2A,$%02X\t\t\t; CB\t%d\n", DB, cval, cval);
fprintf(outputfile, "\t%s\t$2A,$%02X\t\t\t; CB\t%d\n", DB, cval, cval);
else if ((cval & 0xFF00) == 0xFF00)
printf("\t%s\t$5E,$%02X\t\t\t; CFFB\t%d\n", DB, cval&0xFF, cval);
fprintf(outputfile, "\t%s\t$5E,$%02X\t\t\t; CFFB\t%d\n", DB, cval&0xFF, cval);
else
printf("\t%s\t$2C,$%02X,$%02X\t\t; CW\t%d\n", DB, cval&0xFF,(cval>>8)&0xFF, cval);
fprintf(outputfile, "\t%s\t$2C,$%02X,$%02X\t\t; CW\t%d\n", DB, cval&0xFF,(cval>>8)&0xFF, cval);
}
void emit_conststr(long conststr)
{
printf("\t%s\t$2E\t\t\t; CS\n", DB);
fprintf(outputfile, "\t%s\t$2E\t\t\t; CS\n", DB);
emit_data(0, STRING_TYPE, conststr, 0);
}
void emit_addi(int cval)
{
emit_pending_seq();
printf("\t%s\t$38,$%02X\t\t\t; ADDI\t%d\n", DB, cval, cval);
fprintf(outputfile, "\t%s\t$38,$%02X\t\t\t; ADDI\t%d\n", DB, cval, cval);
}
void emit_subi(int cval)
{
emit_pending_seq();
printf("\t%s\t$3A,$%02X\t\t\t; SUBI\t%d\n", DB, cval, cval);
fprintf(outputfile, "\t%s\t$3A,$%02X\t\t\t; SUBI\t%d\n", DB, cval, cval);
}
void emit_andi(int cval)
{
emit_pending_seq();
printf("\t%s\t$3C,$%02X\t\t\t; ANDI\t%d\n", DB, cval, cval);
fprintf(outputfile, "\t%s\t$3C,$%02X\t\t\t; ANDI\t%d\n", DB, cval, cval);
}
void emit_ori(int cval)
{
emit_pending_seq();
printf("\t%s\t$3E,$%02X\t\t\t; ORI\t%d\n", DB, cval, cval);
fprintf(outputfile, "\t%s\t$3E,$%02X\t\t\t; ORI\t%d\n", DB, cval, cval);
}
void emit_lb(void)
{
printf("\t%s\t$60\t\t\t; LB\n", DB);
fprintf(outputfile, "\t%s\t$60\t\t\t; LB\n", DB);
}
void emit_lw(void)
{
printf("\t%s\t$62\t\t\t; LW\n", DB);
fprintf(outputfile, "\t%s\t$62\t\t\t; LW\n", DB);
}
void emit_llb(int index)
{
printf("\t%s\t$64,$%02X\t\t\t; LLB\t[%d]\n", DB, index, index);
fprintf(outputfile, "\t%s\t$64,$%02X\t\t\t; LLB\t[%d]\n", DB, index, index);
}
void emit_llw(int index)
{
printf("\t%s\t$66,$%02X\t\t\t; LLW\t[%d]\n", DB, index, index);
fprintf(outputfile, "\t%s\t$66,$%02X\t\t\t; LLW\t[%d]\n", DB, index, index);
}
void emit_addlb(int index)
{
printf("\t%s\t$B0,$%02X\t\t\t; ADDLB\t[%d]\n", DB, index, index);
fprintf(outputfile, "\t%s\t$B0,$%02X\t\t\t; ADDLB\t[%d]\n", DB, index, index);
}
void emit_addlw(int index)
{
printf("\t%s\t$B2,$%02X\t\t\t; ADDLW\t[%d]\n", DB, index, index);
fprintf(outputfile, "\t%s\t$B2,$%02X\t\t\t; ADDLW\t[%d]\n", DB, index, index);
}
void emit_idxlb(int index)
{
printf("\t%s\t$B8,$%02X\t\t\t; IDXLB\t[%d]\n", DB, index, index);
fprintf(outputfile, "\t%s\t$B8,$%02X\t\t\t; IDXLB\t[%d]\n", DB, index, index);
}
void emit_idxlw(int index)
{
printf("\t%s\t$BA,$%02X\t\t\t; IDXLW\t[%d]\n", DB, index, index);
fprintf(outputfile, "\t%s\t$BA,$%02X\t\t\t; IDXLW\t[%d]\n", DB, index, index);
}
void emit_lab(int tag, int offset, int type)
{
@ -693,12 +692,12 @@ void emit_lab(int tag, int offset, int type)
{
int fixup = fixup_new(tag, type, FIXUP_WORD);
char *taglbl = tag_string(tag, type);
printf("\t%s\t$68\t\t\t; LAB\t%s+%d\n", DB, taglbl, offset);
printf("_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
fprintf(outputfile, "\t%s\t$68\t\t\t; LAB\t%s+%d\n", DB, taglbl, offset);
fprintf(outputfile, "_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
}
else
{
printf("\t%s\t$68,$%02X,$%02X\t\t; LAB\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
fprintf(outputfile, "\t%s\t$68,$%02X,$%02X\t\t; LAB\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
}
}
void emit_law(int tag, int offset, int type)
@ -707,12 +706,12 @@ void emit_law(int tag, int offset, int type)
{
int fixup = fixup_new(tag, type, FIXUP_WORD);
char *taglbl = tag_string(tag, type);
printf("\t%s\t$6A\t\t\t; LAW\t%s+%d\n", DB, taglbl, offset);
printf("_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
fprintf(outputfile, "\t%s\t$6A\t\t\t; LAW\t%s+%d\n", DB, taglbl, offset);
fprintf(outputfile, "_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
}
else
{
printf("\t%s\t$6A,$%02X,$%02X\t\t; LAW\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
fprintf(outputfile, "\t%s\t$6A,$%02X,$%02X\t\t; LAW\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
}
}
void emit_addab(int tag, int offset, int type)
@ -721,12 +720,12 @@ void emit_addab(int tag, int offset, int type)
{
int fixup = fixup_new(tag, type, FIXUP_WORD);
char *taglbl = tag_string(tag, type);
printf("\t%s\t$B4\t\t\t; ADDAB\t%s+%d\n", DB, taglbl, offset);
printf("_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
fprintf(outputfile, "\t%s\t$B4\t\t\t; ADDAB\t%s+%d\n", DB, taglbl, offset);
fprintf(outputfile, "_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
}
else
{
printf("\t%s\t$B4,$%02X,$%02X\t\t; ADDAB\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
fprintf(outputfile, "\t%s\t$B4,$%02X,$%02X\t\t; ADDAB\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
}
}
void emit_addaw(int tag, int offset, int type)
@ -735,12 +734,12 @@ void emit_addaw(int tag, int offset, int type)
{
int fixup = fixup_new(tag, type, FIXUP_WORD);
char *taglbl = tag_string(tag, type);
printf("\t%s\t$B6\t\t\t; ADDAW\t%s+%d\n", DB, taglbl, offset);
printf("_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
fprintf(outputfile, "\t%s\t$B6\t\t\t; ADDAW\t%s+%d\n", DB, taglbl, offset);
fprintf(outputfile, "_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
}
else
{
printf("\t%s\t$B6,$%02X,$%02X\t\t; ADDAW\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
fprintf(outputfile, "\t%s\t$B6,$%02X,$%02X\t\t; ADDAW\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
}
}
void emit_idxab(int tag, int offset, int type)
@ -749,12 +748,12 @@ void emit_idxab(int tag, int offset, int type)
{
int fixup = fixup_new(tag, type, FIXUP_WORD);
char *taglbl = tag_string(tag, type);
printf("\t%s\t$BC\t\t\t; IDXAB\t%s+%d\n", DB, taglbl, offset);
printf("_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
fprintf(outputfile, "\t%s\t$BC\t\t\t; IDXAB\t%s+%d\n", DB, taglbl, offset);
fprintf(outputfile, "_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
}
else
{
printf("\t%s\t$BC,$%02X,$%02X\t\t; IDXAB\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
fprintf(outputfile, "\t%s\t$BC,$%02X,$%02X\t\t; IDXAB\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
}
}
void emit_idxaw(int tag, int offset, int type)
@ -763,37 +762,37 @@ void emit_idxaw(int tag, int offset, int type)
{
int fixup = fixup_new(tag, type, FIXUP_WORD);
char *taglbl = tag_string(tag, type);
printf("\t%s\t$BE\t\t\t; IDXAW\t%s+%d\n", DB, taglbl, offset);
printf("_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
fprintf(outputfile, "\t%s\t$BE\t\t\t; IDXAW\t%s+%d\n", DB, taglbl, offset);
fprintf(outputfile, "_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
}
else
{
printf("\t%s\t$BE,$%02X,$%02X\t\t; IDXAW\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
fprintf(outputfile, "\t%s\t$BE,$%02X,$%02X\t\t; IDXAW\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
}
}
void emit_sb(void)
{
printf("\t%s\t$70\t\t\t; SB\n", DB);
fprintf(outputfile, "\t%s\t$70\t\t\t; SB\n", DB);
}
void emit_sw(void)
{
printf("\t%s\t$72\t\t\t; SW\n", DB);
fprintf(outputfile, "\t%s\t$72\t\t\t; SW\n", DB);
}
void emit_slb(int index)
{
printf("\t%s\t$74,$%02X\t\t\t; SLB\t[%d]\n", DB, index, index);
fprintf(outputfile, "\t%s\t$74,$%02X\t\t\t; SLB\t[%d]\n", DB, index, index);
}
void emit_slw(int index)
{
printf("\t%s\t$76,$%02X\t\t\t; SLW\t[%d]\n", DB, index, index);
fprintf(outputfile, "\t%s\t$76,$%02X\t\t\t; SLW\t[%d]\n", DB, index, index);
}
void emit_dlb(int index)
{
printf("\t%s\t$6C,$%02X\t\t\t; DLB\t[%d]\n", DB, index, index);
fprintf(outputfile, "\t%s\t$6C,$%02X\t\t\t; DLB\t[%d]\n", DB, index, index);
}
void emit_dlw(int index)
{
printf("\t%s\t$6E,$%02X\t\t\t; DLW\t[%d]\n", DB, index, index);
fprintf(outputfile, "\t%s\t$6E,$%02X\t\t\t; DLW\t[%d]\n", DB, index, index);
}
void emit_sab(int tag, int offset, int type)
{
@ -801,12 +800,12 @@ void emit_sab(int tag, int offset, int type)
{
int fixup = fixup_new(tag, type, FIXUP_WORD);
char *taglbl = tag_string(tag, type);
printf("\t%s\t$78\t\t\t; SAB\t%s+%d\n", DB, taglbl, offset);
printf("_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
fprintf(outputfile, "\t%s\t$78\t\t\t; SAB\t%s+%d\n", DB, taglbl, offset);
fprintf(outputfile, "_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
}
else
{
printf("\t%s\t$78,$%02X,$%02X\t\t; SAB\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
fprintf(outputfile, "\t%s\t$78,$%02X,$%02X\t\t; SAB\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
}
}
void emit_saw(int tag, int offset, int type)
@ -815,12 +814,12 @@ void emit_saw(int tag, int offset, int type)
{
int fixup = fixup_new(tag, type, FIXUP_WORD);
char *taglbl = tag_string(tag, type);
printf("\t%s\t$7A\t\t\t; SAW\t%s+%d\n", DB, taglbl, offset);
printf("_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
fprintf(outputfile, "\t%s\t$7A\t\t\t; SAW\t%s+%d\n", DB, taglbl, offset);
fprintf(outputfile, "_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
}
else
{
printf("\t%s\t$7A,$%02X,$%02X\t\t; SAW\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
fprintf(outputfile, "\t%s\t$7A,$%02X,$%02X\t\t; SAW\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
}
}
void emit_dab(int tag, int offset, int type)
@ -829,11 +828,11 @@ void emit_dab(int tag, int offset, int type)
{
int fixup = fixup_new(tag, type, FIXUP_WORD);
char *taglbl = tag_string(tag, type);
printf("\t%s\t$7C\t\t\t; DAB\t%s+%d\n", DB, taglbl, offset);
printf("_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
fprintf(outputfile, "\t%s\t$7C\t\t\t; DAB\t%s+%d\n", DB, taglbl, offset);
fprintf(outputfile, "_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
}
else
printf("\t%s\t$7C,$%02X,$%02X\t\t; DAB\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
fprintf(outputfile, "\t%s\t$7C,$%02X,$%02X\t\t; DAB\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
}
void emit_daw(int tag, int offset, int type)
{
@ -841,36 +840,36 @@ void emit_daw(int tag, int offset, int type)
{
int fixup = fixup_new(tag, type, FIXUP_WORD);
char *taglbl = tag_string(tag, type);
printf("\t%s\t$7E\t\t\t; DAW\t%s+%d\n", DB, taglbl, offset);
printf("_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
fprintf(outputfile, "\t%s\t$7E\t\t\t; DAW\t%s+%d\n", DB, taglbl, offset);
fprintf(outputfile, "_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
}
else
printf("\t%s\t$7E,$%02X,$%02X\t\t; DAW\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
fprintf(outputfile, "\t%s\t$7E,$%02X,$%02X\t\t; DAW\t%d\n", DB, offset&0xFF,(offset>>8)&0xFF, offset);
}
void emit_localaddr(int index)
{
printf("\t%s\t$28,$%02X\t\t\t; LLA\t[%d]\n", DB, index, index);
fprintf(outputfile, "\t%s\t$28,$%02X\t\t\t; LLA\t[%d]\n", DB, index, index);
}
void emit_globaladdr(int tag, int offset, int type)
{
int fixup = fixup_new(tag, type, FIXUP_WORD);
char *taglbl = tag_string(tag, type);
printf("\t%s\t$26\t\t\t; LA\t%s+%d\n", DB, taglbl, offset);
printf("_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
fprintf(outputfile, "\t%s\t$26\t\t\t; LA\t%s+%d\n", DB, taglbl, offset);
fprintf(outputfile, "_F%03d%c\t%s\t%s+%d\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl, offset);
}
void emit_indexbyte(void)
{
printf("\t%s\t$82\t\t\t; IDXB\n", DB);
fprintf(outputfile, "\t%s\t$82\t\t\t; IDXB\n", DB);
}
void emit_indexword(void)
{
printf("\t%s\t$9E\t\t\t; IDXW\n", DB);
fprintf(outputfile, "\t%s\t$9E\t\t\t; IDXW\n", DB);
}
void emit_select(int tag)
{
emit_pending_seq();
printf("\t%s\t$52\t\t\t; SEL\n", DB);
printf("\t%s\t_B%03d-*\n", DW, tag);
fprintf(outputfile, "\t%s\t$52\t\t\t; SEL\n", DB);
fprintf(outputfile, "\t%s\t_B%03d-*\n", DW, tag);
}
void emit_caseblock(int casecnt, int *caseof, int *casetag)
{
@ -879,144 +878,144 @@ void emit_caseblock(int casecnt, int *caseof, int *casetag)
if (casecnt < 1 || casecnt > 256)
parse_error("Switch count under/overflow\n");
emit_pending_seq();
printf("\t%s\t$%02lX\t\t\t; CASEBLOCK\n", DB, casecnt & 0xFF);
fprintf(outputfile, "\t%s\t$%02X\t\t\t; CASEBLOCK\n", DB, casecnt & 0xFF);
for (i = 0; i < casecnt; i++)
{
printf("\t%s\t$%04lX\n", DW, caseof[i] & 0xFFFF);
printf("\t%s\t_B%03d-*\n", DW, casetag[i]);
fprintf(outputfile, "\t%s\t$%04X\n", DW, caseof[i] & 0xFFFF);
fprintf(outputfile, "\t%s\t_B%03d-*\n", DW, casetag[i]);
}
}
void emit_breq(int tag)
{
printf("\t%s\t$22\t\t\t; BREQ\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
fprintf(outputfile, "\t%s\t$22\t\t\t; BREQ\t_B%03d\n", DB, tag);
fprintf(outputfile, "\t%s\t_B%03d-*\n", DW, tag);
}
void emit_brne(int tag)
{
printf("\t%s\t$24\t\t\t; BRNE\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
fprintf(outputfile, "\t%s\t$24\t\t\t; BRNE\t_B%03d\n", DB, tag);
fprintf(outputfile, "\t%s\t_B%03d-*\n", DW, tag);
}
void emit_brfls(int tag)
{
printf("\t%s\t$4C\t\t\t; BRFLS\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
fprintf(outputfile, "\t%s\t$4C\t\t\t; BRFLS\t_B%03d\n", DB, tag);
fprintf(outputfile, "\t%s\t_B%03d-*\n", DW, tag);
}
void emit_brtru(int tag)
{
printf("\t%s\t$4E\t\t\t; BRTRU\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
fprintf(outputfile, "\t%s\t$4E\t\t\t; BRTRU\t_B%03d\n", DB, tag);
fprintf(outputfile, "\t%s\t_B%03d-*\n", DW, tag);
}
void emit_brnch(int tag)
{
emit_pending_seq();
printf("\t%s\t$50\t\t\t; BRNCH\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
fprintf(outputfile, "\t%s\t$50\t\t\t; BRNCH\t_B%03d\n", DB, tag);
fprintf(outputfile, "\t%s\t_B%03d-*\n", DW, tag);
}
void emit_brand(int tag)
{
emit_pending_seq();
printf("\t%s\t$AC\t\t\t; BRAND\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
fprintf(outputfile, "\t%s\t$AC\t\t\t; BRAND\t_B%03d\n", DB, tag);
fprintf(outputfile, "\t%s\t_B%03d-*\n", DW, tag);
}
void emit_bror(int tag)
{
emit_pending_seq();
printf("\t%s\t$AE\t\t\t; BROR\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
fprintf(outputfile, "\t%s\t$AE\t\t\t; BROR\t_B%03d\n", DB, tag);
fprintf(outputfile, "\t%s\t_B%03d-*\n", DW, tag);
}
void emit_brgt(int tag)
{
emit_pending_seq();
printf("\t%s\t$A0\t\t\t; BRGT\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
fprintf(outputfile, "\t%s\t$A0\t\t\t; BRGT\t_B%03d\n", DB, tag);
fprintf(outputfile, "\t%s\t_B%03d-*\n", DW, tag);
}
void emit_brlt(int tag)
{
emit_pending_seq();
printf("\t%s\t$A2\t\t\t; BRLT\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
fprintf(outputfile, "\t%s\t$A2\t\t\t; BRLT\t_B%03d\n", DB, tag);
fprintf(outputfile, "\t%s\t_B%03d-*\n", DW, tag);
}
void emit_incbrle(int tag)
{
emit_pending_seq();
printf("\t%s\t$A4\t\t\t; INCBRLE\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
fprintf(outputfile, "\t%s\t$A4\t\t\t; INCBRLE\t_B%03d\n", DB, tag);
fprintf(outputfile, "\t%s\t_B%03d-*\n", DW, tag);
}
void emit_addbrle(int tag)
{
emit_pending_seq();
printf("\t%s\t$A6\t\t\t; ADDBRLE\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
fprintf(outputfile, "\t%s\t$A6\t\t\t; ADDBRLE\t_B%03d\n", DB, tag);
fprintf(outputfile, "\t%s\t_B%03d-*\n", DW, tag);
}
void emit_decbrge(int tag)
{
emit_pending_seq();
printf("\t%s\t$A8\t\t\t; DECBRGE\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
fprintf(outputfile, "\t%s\t$A8\t\t\t; DECBRGE\t_B%03d\n", DB, tag);
fprintf(outputfile, "\t%s\t_B%03d-*\n", DW, tag);
}
void emit_subbrge(int tag)
{
emit_pending_seq();
printf("\t%s\t$AA\t\t\t; SUBBRGE\t_B%03d\n", DB, tag);
printf("\t%s\t_B%03d-*\n", DW, tag);
fprintf(outputfile, "\t%s\t$AA\t\t\t; SUBBRGE\t_B%03d\n", DB, tag);
fprintf(outputfile, "\t%s\t_B%03d-*\n", DW, tag);
}
void emit_call(int tag, int type)
{
if (type == CONST_TYPE)
{
printf("\t%s\t$54\t\t\t; CALL\t%i\n", DB, tag);
printf("\t%s\t%i\t\t\n", DW, tag);
fprintf(outputfile, "\t%s\t$54\t\t\t; CALL\t%i\n", DB, tag);
fprintf(outputfile, "\t%s\t%i\t\t\n", DW, tag);
}
else
{
int fixup = fixup_new(tag, type, FIXUP_WORD);
char *taglbl = tag_string(tag, type);
printf("\t%s\t$54\t\t\t; CALL\t%s\n", DB, taglbl);
printf("_F%03d%c\t%s\t%s\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl);
fprintf(outputfile, "\t%s\t$54\t\t\t; CALL\t%s\n", DB, taglbl);
fprintf(outputfile, "_F%03d%c\t%s\t%s\t\t\n", fixup, LBL, DW, type & EXTERN_TYPE ? "0" : taglbl);
}
}
void emit_ical(void)
{
printf("\t%s\t$56\t\t\t; ICAL\n", DB);
fprintf(outputfile, "\t%s\t$56\t\t\t; ICAL\n", DB);
}
void emit_leave(void)
{
emit_pending_seq();
if (localsize)
printf("\t%s\t$5A,$%02X\t\t\t; LEAVE\t%d\n", DB, localsize, localsize);
fprintf(outputfile, "\t%s\t$5A,$%02X\t\t\t; LEAVE\t%d\n", DB, localsize, localsize);
else
printf("\t%s\t$5C\t\t\t; RET\n", DB);
fprintf(outputfile, "\t%s\t$5C\t\t\t; RET\n", DB);
}
void emit_ret(void)
{
emit_pending_seq();
printf("\t%s\t$5C\t\t\t; RET\n", DB);
fprintf(outputfile, "\t%s\t$5C\t\t\t; RET\n", DB);
}
void emit_enter(int cparams)
{
if (localsize)
printf("\t%s\t$58,$%02X,$%02X\t\t; ENTER\t%d,%d\n", DB, localsize, cparams, localsize, cparams);
fprintf(outputfile, "\t%s\t$58,$%02X,$%02X\t\t; ENTER\t%d,%d\n", DB, localsize, cparams, localsize, cparams);
}
void emit_start(void)
{
printf("_INIT%c\n", LBL);
fprintf(outputfile, "_INIT%c\n", LBL);
outflags |= INIT;
defs++;
}
void emit_drop(void)
{
emit_pending_seq();
printf("\t%s\t$30\t\t\t; DROP \n", DB);
fprintf(outputfile, "\t%s\t$30\t\t\t; DROP \n", DB);
}
void emit_drop2(void)
{
emit_pending_seq();
printf("\t%s\t$32\t\t\t; DROP2\n", DB);
fprintf(outputfile, "\t%s\t$32\t\t\t; DROP2\n", DB);
}
void emit_dup(void)
{
emit_pending_seq();
printf("\t%s\t$34\t\t\t; DUP\n", DB);
fprintf(outputfile, "\t%s\t$34\t\t\t; DUP\n", DB);
}
int emit_unaryop(t_token op)
{
@ -1024,19 +1023,19 @@ int emit_unaryop(t_token op)
switch (op)
{
case NEG_TOKEN:
printf("\t%s\t$90\t\t\t; NEG\n", DB);
fprintf(outputfile, "\t%s\t$90\t\t\t; NEG\n", DB);
break;
case COMP_TOKEN:
printf("\t%s\t$92\t\t\t; COMP\n", DB);
fprintf(outputfile, "\t%s\t$92\t\t\t; COMP\n", DB);
break;
case LOGIC_NOT_TOKEN:
printf("\t%s\t$80\t\t\t; NOT\n", DB);
fprintf(outputfile, "\t%s\t$80\t\t\t; NOT\n", DB);
break;
case INC_TOKEN:
printf("\t%s\t$8C\t\t\t; INCR\n", DB);
fprintf(outputfile, "\t%s\t$8C\t\t\t; INCR\n", DB);
break;
case DEC_TOKEN:
printf("\t%s\t$8E\t\t\t; DECR\n", DB);
fprintf(outputfile, "\t%s\t$8E\t\t\t; DECR\n", DB);
break;
case BPTR_TOKEN:
emit_lb();
@ -1056,52 +1055,52 @@ int emit_op(t_token op)
switch (op)
{
case MUL_TOKEN:
printf("\t%s\t$86\t\t\t; MUL\n", DB);
fprintf(outputfile, "\t%s\t$86\t\t\t; MUL\n", DB);
break;
case DIV_TOKEN:
printf("\t%s\t$88\t\t\t; DIV\n", DB);
fprintf(outputfile, "\t%s\t$88\t\t\t; DIV\n", DB);
break;
case MOD_TOKEN:
printf("\t%s\t$8A\t\t\t; MOD\n", DB);
fprintf(outputfile, "\t%s\t$8A\t\t\t; MOD\n", DB);
break;
case ADD_TOKEN:
printf("\t%s\t$82\t\t\t; ADD \n", DB);
fprintf(outputfile, "\t%s\t$82\t\t\t; ADD \n", DB);
break;
case SUB_TOKEN:
printf("\t%s\t$84\t\t\t; SUB \n", DB);
fprintf(outputfile, "\t%s\t$84\t\t\t; SUB \n", DB);
break;
case SHL_TOKEN:
printf("\t%s\t$9A\t\t\t; SHL\n", DB);
fprintf(outputfile, "\t%s\t$9A\t\t\t; SHL\n", DB);
break;
case SHR_TOKEN:
printf("\t%s\t$9C\t\t\t; SHR\n", DB);
fprintf(outputfile, "\t%s\t$9C\t\t\t; SHR\n", DB);
break;
case AND_TOKEN:
printf("\t%s\t$94\t\t\t; AND \n", DB);
fprintf(outputfile, "\t%s\t$94\t\t\t; AND \n", DB);
break;
case OR_TOKEN:
printf("\t%s\t$96\t\t\t; OR \n", DB);
fprintf(outputfile, "\t%s\t$96\t\t\t; OR \n", DB);
break;
case EOR_TOKEN:
printf("\t%s\t$98\t\t\t; XOR\n", DB);
fprintf(outputfile, "\t%s\t$98\t\t\t; XOR\n", DB);
break;
case EQ_TOKEN:
printf("\t%s\t$40\t\t\t; ISEQ\n", DB);
fprintf(outputfile, "\t%s\t$40\t\t\t; ISEQ\n", DB);
break;
case NE_TOKEN:
printf("\t%s\t$42\t\t\t; ISNE\n", DB);
fprintf(outputfile, "\t%s\t$42\t\t\t; ISNE\n", DB);
break;
case GE_TOKEN:
printf("\t%s\t$48\t\t\t; ISGE\n", DB);
fprintf(outputfile, "\t%s\t$48\t\t\t; ISGE\n", DB);
break;
case LT_TOKEN:
printf("\t%s\t$46\t\t\t; ISLT\n", DB);
fprintf(outputfile, "\t%s\t$46\t\t\t; ISLT\n", DB);
break;
case GT_TOKEN:
printf("\t%s\t$44\t\t\t; ISGT\n", DB);
fprintf(outputfile, "\t%s\t$44\t\t\t; ISGT\n", DB);
break;
case LE_TOKEN:
printf("\t%s\t$4A\t\t\t; ISLE\n", DB);
fprintf(outputfile, "\t%s\t$4A\t\t\t; ISLE\n", DB);
break;
case COMMA_TOKEN:
break;
@ -2041,7 +2040,7 @@ int emit_pending_seq()
emit_brlt(op->tag);
break;
case CODETAG_CODE:
printf("_B%03d%c\n", op->tag, LBL);
fprintf(outputfile, "_B%03d%c\n", op->tag, LBL);
break;
case NOP_CODE:
break;

View File

@ -449,6 +449,7 @@ end
def idmatch(nameptr, len, idptr, idcnt)
byte i
if len > ID_LEN; len = ID_LEN; fin
while idcnt
if len == idptr->idname
i = 1; while i <= len and nameptr->[i - 1] == idptr->idname.[i]; i++; loop
@ -516,6 +517,7 @@ def size_iddata(type, varsize, initsize)#0
end
def new_idglobal(nameptr, len, type, value, cparms, cvals)#0
if idmatch(nameptr, len, idglobal_tbl, globals); exit_err(ERR_DUP|ERR_ID); fin
if len > ID_LEN; len = ID_LEN; fin
lastglobal=>idval = value
lastglobal=>idtype = type
lastglobal->funcparms = cparms
@ -588,6 +590,7 @@ def init_idglobal#0
end
def new_idlocal(nameptr, len, type, size)#0
if idmatch(nameptr, len, @idlocal_tbl, locals); exit_err(ERR_DUP|ERR_ID); fin
if len > ID_LEN; len = ID_LEN; fin
lastlocal=>idval = framesize
lastlocal=>idtype = type | LOCAL_TYPE
nametostr(nameptr, len, lastlocal + idname)

View File

@ -9,8 +9,6 @@ char *statement, *tokenstr, *scanpos = "", *strpos = "";
t_token scantoken = EOL_TOKEN, prevtoken;
int tokenlen;
long constval;
FILE* inputfile;
char *filename;
int lineno = 0;
FILE* outer_inputfile = NULL;
char* outer_filename;
@ -448,14 +446,6 @@ int next_line(void)
t_token token;
char* new_filename;
strpos = conststr;
if (inputfile == NULL)
{
/*
* First-time init
*/
inputfile = stdin;
filename = "<stdin>";
}
if (*scanpos == ';')
{
statement = ++scanpos;
@ -500,7 +490,7 @@ int next_line(void)
inputline[len-1] = '\0';
lineno++;
scantoken = EOL_TOKEN;
printf("; %s: %04d: %s\n", filename, lineno, inputline);
fprintf(outputfile, "; %s: %04d: %s\n", filename, lineno, inputline);
}
token = scan();
/*

View File

@ -1,11 +1,13 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "plasm.h"
#define LVALUE 0
#define RVALUE 1
#define MAX_LAMBDA 64
int id_match(char *name, int len, char *id);
int parse_mods(void);
int infunc = 0, break_tag = 0, cont_tag = 0, stack_loop = 0;
@ -558,7 +560,7 @@ t_opseq *parse_value(t_opseq *codeseq, int rvalue, int *stackdepth)
parse_error("Using BYTE value as a pointer");
else
deref++;
type = (type & PTR_TYPE) | (scantoken == PTRB_TOKEN) ? BYTE_TYPE : WORD_TYPE; // Type override
type = (type & PTR_TYPE) | ((scantoken == PTRB_TOKEN) ? BYTE_TYPE : WORD_TYPE); // Type override
if (!parse_const(&const_offset))
{
/*
@ -1221,7 +1223,7 @@ int parse_stmnt(void)
}
return (scan() == EOL_TOKEN);
}
int parse_var(int type, long basesize)
int parse_var(int type, long basesize, int ignore_var)
{
char *idstr;
long constval;
@ -1267,7 +1269,7 @@ int parse_var(int type, long basesize)
else
parse_error("Bad variable initializer");
}
else
else if (!ignore_var)
{
if (idlen)
id_add(idstr, idlen, type, size);
@ -1341,7 +1343,7 @@ int parse_struc(void)
scan();
return (1);
}
int parse_vars(int type)
int parse_vars(int type, int ignore_vars)
{
long value;
int idlen, size, cfnparms, emit = 0;
@ -1406,7 +1408,7 @@ int parse_vars(int type)
scan_rewind(tokenstr);
if (type & WORD_TYPE)
cfnvals *= 2;
do parse_var(type, cfnvals); while (scantoken == COMMA_TOKEN);
do parse_var(type, cfnvals, ignore_vars); while (scantoken == COMMA_TOKEN);
emit = type == GLOBAL_TYPE;
break;
case PREDEF_TOKEN:
@ -1463,13 +1465,18 @@ int parse_vars(int type)
}
int parse_mods(void)
{
int i, ignore_emit;
if (scantoken == IMPORT_TOKEN)
{
if (scan() != ID_TOKEN)
parse_error("Bad import definition");
emit_moddep(tokenstr, tokenlen);
for (i = 0; i < tokenlen; i++)
tokenstr[i] = toupper(tokenstr[i]);
if (!(ignore_emit = id_match(tokenstr, tokenlen, modfile)))
emit_moddep(tokenstr, tokenlen);
scan();
while (parse_vars(EXTERN_TYPE)) next_line();
while (parse_vars(EXTERN_TYPE, ignore_emit)) next_line();
if (scantoken != END_TOKEN)
parse_error("Missing END");
scan();
@ -1549,7 +1556,7 @@ int parse_defs(void)
{
case CONST_TOKEN:
case STRUC_TOKEN:
return parse_vars(GLOBAL_TYPE);
return parse_vars(GLOBAL_TYPE, FALSE);
case EXPORT_TOKEN:
if (scan() != DEF_TOKEN && scantoken != ASM_TOKEN)
parse_error("Bad export definition");
@ -1617,7 +1624,7 @@ int parse_defs(void)
/*
* Parse local vars
*/
while (parse_vars(LOCAL_TYPE)) next_line();
while (parse_vars(LOCAL_TYPE, FALSE)) next_line();
emit_enter(cfnparms);
prevstmnt = 0;
while (parse_stmnt()) next_line();
@ -1714,7 +1721,7 @@ int parse_module(void)
if (next_line())
{
while (parse_mods()) next_line();
while (parse_vars(GLOBAL_TYPE)) next_line();
while (parse_vars(GLOBAL_TYPE, FALSE)) next_line();
while (parse_defs()) next_line();
emit_bytecode_seg();
emit_start();

View File

@ -1 +1,2 @@
int id_match(char *name, int len, char *id);
int parse_module(void);

View File

@ -138,10 +138,13 @@ def parse_constval
is ID_TKN
size = 2
idptr = lookup_id(tknptr, tknlen)
type = idptr=>idtype
if not idptr; exit_err(ERR_INVAL|ERR_CONST); fin
type = idptr=>idtype
if type & (FUNC_TYPE|ADDR_TYPE)
if mod <> 8; exit_err(ERR_INVAL|ERR_CONST); fin
type = CONSTADDR_TYPE
elsif type <> CONST_TYPE
exit_err(ERR_INVAL|ERR_CONST)
fin
value = idptr=>idval
break
@ -1064,8 +1067,8 @@ def parse_struc#0
scan
end
def parse_vars(type)
byte idlen, size, cfnparms, cfnvals
word value, idptr
byte idlen, cfnparms, cfnvals
word size, value, idptr
when token
is SYSFLAGS_TKN

View File

@ -1,11 +1,16 @@
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <ctype.h>
#include "plasm.h"
int outflags = 0;
FILE *inputfile = NULL, *outputfile;
char *filename, asmfile[128], modfile[17];
int main(int argc, char **argv)
{
int j, i, flags = 0;
int k, j, i, flags = 0;
for (i = 1; i < argc; i++)
{
if (argv[i][0] == '-')
@ -32,11 +37,57 @@ int main(int argc, char **argv)
}
}
}
else
{
if (inputfile == NULL)
{
filename = argv[i];
inputfile = fopen(filename, "r");
if (!inputfile)
{
printf("Error opening input file: %s\n", filename);
exit(1);
}
strcpy(asmfile, filename);
j = strlen(asmfile);
while (j && asmfile[j] != '.')
{
asmfile[j] = '\0';
j--;
}
asmfile[j+1] = 'a';
outputfile = fopen(asmfile, "w");
if (!outputfile)
{
printf("Error opening output file %s\n", asmfile);
exit(1);
}
while (j && asmfile[j-1] != '/')
j--;
k = 1;
while (asmfile[j] != '.')
modfile[k++] = toupper(asmfile[j++]);
modfile[k] = '\0';
modfile[0] = k - 1;
}
else
{
printf("Too many input files\n");
exit(1);
}
}
}
if (inputfile == NULL)
{
printf("Usage: %s [-AMONW] <inputfile>", argv[0]);
return (0);
}
emit_flags(outflags);
if (parse_module())
{
fprintf(stderr, "Compilation complete.\n");
}
fclose(inputfile);
fclose(outputfile);
return (0);
}

View File

@ -9,7 +9,11 @@
#define SYSFLAGS (1<<5)
#define WARNINGS (1<<6)
#define NO_COMBINE (1<<7)
#define FALSE 0
#define TRUE (!FALSE)
extern int outflags;
extern FILE *inputfile, *outputfile;
extern char *filename, modfile[17];
#include "tokens.h"
#include "lex.h"
#include "symbols.h"

View File

@ -5,6 +5,7 @@ include "inc/longjmp.plh"
//
// Tokens
//
const ID_LEN = 32
const ID_TKN = $D6 // V
const CHR_TKN = $C3 // C
const INT_TKN = $C9 // I
@ -507,7 +508,7 @@ include "toolsrc/parse.pla"
//
// Look at command line arguments and compile module
//
puts("PLASMA Compiler, Version 2.0 ALPHA1\n")
puts("PLASMA Compiler, Version 2.0 ALPHA2\n")
arg = argNext(argFirst)
if ^arg and ^(arg + 1) == '-'
opt = arg + 2

View File

@ -12,23 +12,6 @@ char[64] path, wildname
res[t_fileinfo] fileinfo
res[t_fileentry] fileentry
//
// Convert byte to two hex chars
//
def putb(b)#0
char h
h = ((b >> 4) & $0F) + '0'
if h > '9'
h = h + 7
fin
putc(h)
h = (b & $0F) + '0'
if h > '9'
h = h + 7
fin
putc(h)
end
//
// Copy string with upper case conversion
//
def struprcpy(dst, src)#0
@ -46,23 +29,12 @@ def struprcpy(dst, src)#0
fin
^dst = ^src
end
def filefrompath(filestr, pathstr)#0
byte i
for i = ^pathstr downto 1
if pathstr->[i] == '/'
break
fin
next
^filestr = ^pathstr - i
memcpy(filestr + 1, pathstr + 1 + i, ^filestr)
end
//
// Print out a directory entry
//
def printentry(entryptr)#0
char type, pad, eofstr[12]
puts(entryptr)
when entryptr->entry_type
is $0F // Is it a directory?
@ -88,12 +60,12 @@ def printentry(entryptr)#0
for pad = eofstr to 9
putc(' ')
next
puts(@eofstr)
puts(@eofstr)
putln
end
def printentries(pathstr, entries, num)#0
byte page
puts(pathstr); putln
puts("=NAME==========TYPE===AUX====LENGTH=\n")
page = 20

View File

@ -16,7 +16,7 @@ res[t_fileinfo] srcfileinfo, dstfileinfo
//
def pathcpy(dst, src)#0
byte i, chr
if ^src
for i = 1 to ^src
chr = src->[i]
@ -52,7 +52,7 @@ end
def pathdiff(path1, path2)#1
byte i, d
char[64] abs1, abs2
abspath(@abs1, path1)
abspath(@abs2, path2)
@ -67,17 +67,6 @@ def pathdiff(path1, path2)#1
next
return FALSE
end
def filefrompath(filestr, pathstr)#0
byte i
for i = ^pathstr + 1 downto 1
if pathstr->[i] == '/'
break
fin
next
^filestr = ^pathstr - i
memcpy(filestr + 1, pathstr + 1 + i, ^filestr)
end
//
// Check destination path
//
@ -108,14 +97,14 @@ def copyfiles(srcfile, dstfile)#0
char[64] srcfilepath
char[64] dstfilepath
char[16] wildname
//
// Check if copying a directory
//
strcpy(@srcpath, srcfile)
wildname = 0
if fileio:getfileinfo(@srcpath, @srcfileinfo) <> FILE_ERR_OK or (srcfileinfo.storage_type & $0D <> $0D)
filefrompath(@wildname, @srcpath)
fileFromPath(@wildname, @srcpath)
srcpath = srcpath - wildname
fin
entrylist, entrycnt = matchList(@srcpath, @wildname)
@ -186,7 +175,7 @@ def copyfiles(srcfile, dstfile)#0
puts(" ==> "); puts(@dstfilepath); putln
fin
entry = entry + t_fileentry
entrycnt--
entrycnt--
loop
heaprelease(entrylist)
fin

View File

@ -25,17 +25,6 @@ def struprcpy(dst, src)#0
fin
^dst = ^src
end
def filefrompath(filestr, pathstr)#0
byte i
for i = ^pathstr downto 1
if pathstr->[i] == '/'
break
fin
next
^filestr = ^pathstr - i
memcpy(filestr + 1, pathstr + 1 + i, ^filestr)
end
//
// Check filename
//
@ -81,9 +70,8 @@ def delfiles(delfile)#0
strcpy(@delpath, delfile)
wildname = 0
//if fileio:getfileinfo(@delpath, @fileinfo) <> FILE_ERR_OK or fileinfo.file_type <> $0F
if delpath[delpath] <> '/'
filefrompath(@wildname, @delpath)
fileFromPath(@wildname, @delpath)
delpath = delpath - wildname
fin
//
@ -115,7 +103,7 @@ def delfiles(delfile)#0
fileio:destroy(@delfilepath)
fin
entry = entry + t_fileentry
entrycnt--
entrycnt--
loop
elsif not wildname
puts("Not found: "); puts(@delpath); puts("/"); puts(@wildname); putln
@ -156,7 +144,7 @@ if not except(exit)
strcpy(@path,fileptr)
strcat(@path, "/")
delfiles(@path)
fin
fin
delfiles(fileptr)
fileptr = fileptr + ^fileptr + 1
filecnt--

View File

@ -8,23 +8,23 @@ var arg, type, aux
//
// Convert byte to two hex chars
//
def putb(b)#0
char h
h = ((b >> 4) & $0F) + '0'
if h > '9'
h = h + 7
fin
putc(h)
h = (b & $0F) + '0'
if h > '9'
h = h + 7
fin
putc(h)
end
//def putb(b)#0
// char h
//
// h = ((b >> 4) & $0F) + '0'
// if h > '9'
// h = h + 7
// fin
// putc(h)
// h = (b & $0F) + '0'
// if h > '9'
// h = h + 7
// fin
// putc(h)
//end
def htoi(hexptr)
var val, i, n
val = 0
for i = 1 to ^hexptr
n = toupper(^(hexptr + i)) - '0'

View File

@ -52,7 +52,7 @@ byte perr, refauto
// String pool.
//
byte autorun[] = "AUTORUN"
byte verstr[] = "\nPLASMA ALPHA1"
byte verstr[] = "\nPLASMA ALPHA2"
byte freestr[] = "MEM FREE:$"
byte errorstr[] = "ERR:$"
byte prompt[] = "PLASMA"
@ -911,7 +911,7 @@ end
//
def lookupextern(esd, index)#1
word sym, addr
byte str[16]
byte str[33]
while ^esd
sym = esd
esd = sym + dcitos(sym, @str)

View File

@ -946,7 +946,7 @@ end
//
def lookupextern(esd, index)#1
word sym, addr
byte str[16]
byte str[33]
sym = lookupidx(esd, index)
if sym
addr = lookuptbl(sym, symtbl)
@ -1377,7 +1377,7 @@ heap = @lastdef
//
// Print PLASMA version
//
prstr("PLASMA 2.0 ALPHA1 64K\n")//; prbyte(version.1); cout('.'); prbyte(version.0); crout
prstr("PLASMA 2.0 ALPHA2 64K\n")//; prbyte(version.1); cout('.'); prbyte(version.0); crout
//
// Init symbol table.
//

View File

@ -988,7 +988,7 @@ end
//
def lookupextern(esd, index)#1
word sym, addr
byte str[16]
byte str[33]
sym = lookupidx(esd, index)
if sym
addr = lookuptbl(sym, symtbl)
@ -1454,7 +1454,7 @@ heap = @lastdef
//
// Print PLASMA version
//
prstr("PLASMA 2.0 ALPHA1 128K\n")//; prbyte(version.1); cout('.'); prbyte(version.0); crout
prstr("PLASMA 2.0 ALPHA2 128K\n")//; prbyte(version.1); cout('.'); prbyte(version.0); crout
//
// Init symbol table.
//

View File

@ -1003,7 +1003,7 @@ end
//
def lookupextern(esd, index)#1
word sym, addr
byte str[16]
byte str[33]
sym = lookupidx(esd, index)
if sym
addr = lookuptbl(sym, symtbl)
@ -1263,7 +1263,7 @@ cmdlnptr = @cmdln
// Print PLASMA version
//
init_cons
prstr("PLASMA 2.0 ALPHA1\n")//; putb(version.1); putc('.'); putb(version.0); putln
prstr("PLASMA 2.0 ALPHA2\n")//; putb(version.1); putc('.'); putb(version.0); putln
prstr("MEM:$"); prword(availheap); crout
//
// Exec command line parser

View File

@ -1014,7 +1014,7 @@ end
//
def lookupextern(esd, index)#1
word sym, addr
byte str[16]
byte str[33]
sym = lookupidx(esd, index)
if sym
addr = lookuptbl(sym, symtbl)
@ -1286,7 +1286,7 @@ cmdlnptr = @cmdln
// Print PLASMA version
//
init_cons
prstr("PLASMA 2.0 ALPHA1 JITC\n")//; putb(version.1); putc('.'); putb(version.0); putln
prstr("PLASMA 2.0 ALPHA2 JITC\n")//; putb(version.1); putc('.'); putb(version.0); putln
prstr("MEM:$"); prword(availheap); crout
//
// Exec command line parser

View File

@ -712,7 +712,7 @@ end
asm cout(c)#0
LDA ESTKL,X
INX
JMP $FFD2
JMP $FFD2
end
asm cin()#1
DEX
@ -839,7 +839,7 @@ end
//
def lookupextern(esd, index)#1
word sym, addr
byte str[16]
byte str[33]
while ^esd
sym = esd
esd = sym + dcitos(sym, @str)

View File

@ -509,6 +509,10 @@ void call(uword pc)
mem_data[0x1FF] = i;
PUSH(0x1FF);
break;
case 9: // LIBRARY STDLIB::PUTB
i = UPOP;
printf("%02X", i);
break;
case 10: // LIBRARY STDLIB::PUTH
i = UPOP;
printf("%04X", i);