1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-07-08 09:28:57 +00:00

Merge pull request #11 from dschmenk/master

Merge latest upstream changes
This commit is contained in:
ZornsLemma 2018-03-16 21:36:05 +00:00 committed by GitHub
commit 55711af895
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 213 additions and 97 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
# 2/6/2018 PLASMA 1.0 Available! # 3/13/2018 PLASMA 1.1 Available!
[Download and read the Release Notes](https://github.com/dschmenk/PLASMA/blob/master/doc/Version%201.0.md) [Download and read the Release Notes](https://github.com/dschmenk/PLASMA/blob/master/doc/Version%201.1.md)
# The PLASMA Programming Language # The PLASMA Programming Language

View File

@ -1,16 +1,16 @@
# PLASMA Version 1.0 # PLASMA Version 1.1
Welcome to PLASMA: the Grand Unifying Platform for the Apple 1, ][, and ///. Welcome to PLASMA: the Grand Unifying Platform for the Apple 1, ][, and ///.
Download the four disk images (three if you don't plan to boot an Apple ///): Download the four disk images (three if you don't plan to boot an Apple ///):
[PLASMA 1.0 System and ProDOS Boot](https://github.com/dschmenk/PLASMA/blob/master/PLASMA-SYS1.PO?raw=true) [PLASMA 1.1 System and ProDOS Boot](https://github.com/dschmenk/PLASMA/blob/master/PLASMA-SYS1.PO?raw=true)
[PLASMA 1.0 Build Tools](https://github.com/dschmenk/PLASMA/blob/master/PLASMA-BLD1.PO?raw=true) [PLASMA 1.1 Build Tools](https://github.com/dschmenk/PLASMA/blob/master/PLASMA-BLD1.PO?raw=true)
[PLASMA 1.0 Demos](https://github.com/dschmenk/PLASMA/blob/master/PLASMA-DEM1.PO?raw=true) [PLASMA 1.1 Demos](https://github.com/dschmenk/PLASMA/blob/master/PLASMA-DEM1.PO?raw=true)
[PLASMA 1.0 Apple /// SOS Boot ](https://github.com/dschmenk/PLASMA/blob/master/PLASMA-SOS1.PO?raw=true) [PLASMA 1.1 Apple /// SOS Boot ](https://github.com/dschmenk/PLASMA/blob/master/PLASMA-SOS1.PO?raw=true)
PLASMA can be run from floppies, System in Drive 1, and Build or Demos in Drive 2. Mass storage is the recommended installation that looks like (replacing HARDISK with your volume name of choice): PLASMA can be run from floppies, System in Drive 1, and Build or Demos in Drive 2. Mass storage is the recommended installation that looks like (replacing HARDISK with your volume name of choice):
@ -98,6 +98,12 @@ There is a [YouTube playlist](https://www.youtube.com/playlist?list=PLlPKgUMQbJ7
- The documentation is sparse and incomplete. Yep, could use your help... - The documentation is sparse and incomplete. Yep, could use your help...
# Changes in PLASMA for 1.1
1. All known bugs are fixed
2. PLASM compiler received a little performance boost with an assembly language helper for ID/keyword lexical scanner
# Changes in PLASMA for 1.0 # Changes in PLASMA for 1.0
If you have been programming in PLASMA before, the 1.0 version has some major and minor changes that you should be aware of: If you have been programming in PLASMA before, the 1.0 version has some major and minor changes that you should be aware of:

View File

@ -121,15 +121,15 @@ $(PLVM): vmsrc/plvm.c
cc vmsrc/plvm.c -o $(PLVM) cc vmsrc/plvm.c -o $(PLVM)
$(PLVMZP_APL): FORCE $(PLVMZP_APL): FORCE
-mkdir rel -mkdir -p rel
-mkdir rel/apple -mkdir -p rel/apple
-rm vmsrc/plvmzp.inc -rm -f vmsrc/plvmzp.inc
-ln -s apple/plvmzp.inc vmsrc/plvmzp.inc -ln -s apple/plvmzp.inc vmsrc/plvmzp.inc
$(PLVMZP_C64): FORCE $(PLVMZP_C64): FORCE
-mkdir rel -mkdir -p rel
-mkdir rel/c64 -mkdir -p rel/c64
-rm vmsrc/plvmzp.inc -rm -f vmsrc/plvmzp.inc
-ln -s c64/plvmzp.inc vmsrc/plvmzp.inc -ln -s c64/plvmzp.inc vmsrc/plvmzp.inc
FORCE: FORCE:

View File

@ -85,7 +85,7 @@ def vals123#3
return 1, 2, 3 return 1, 2, 3
end end
export def main(range)#0 export def main(range)#0
byte a, b, c word a, b, c
word lambda word lambda
a = 10 a = 10
@ -127,6 +127,14 @@ export def main(range)#0
drop, b, drop = vals123 drop, b, drop = vals123
drop, drop, c = vals123 drop, drop, c = vals123
puts("a, b, c = "); puti(a); puts(", "); puti(b); puts(", "); puti(c); putln puts("a, b, c = "); puti(a); puts(", "); puti(b); puts(", "); puti(c); putln
puts(" 7 / 3 = "); puti(7/3); puts(" ; 7 % 3 = "); puti(7%3); putln
puts(" 7 / -3 = "); puti(7/-3); puts("; 7 % -3 = "); puti(7%-3); putln
puts("-7 / 3 = "); puti(-7/3); puts("; -7 % 3 = "); puti(-7%3); putln
puts("-7 / -3 = "); puti(-7/-3); puts(" ; -7 % -3 = "); puti(-7%-3); putln
a,b=divmod(7,3); puts("divmod( 7, 3) = "); puti(a); puts(", "); puti(b); putln
a,b=divmod(7,-3); puts("divmod( 7,-3) = "); puti(a); puts(", "); puti(b); putln
a,b=divmod(-7,3); puts("divmod(-7, 3) = "); puti(a); puts(", "); puti(b); putln
a,b=divmod(-7,-3);puts("divmod(-7,-3) = "); puti(a); puts(", "); puti(b); putln
end end
def dummy(zz)#2 def dummy(zz)#2

View File

@ -670,6 +670,7 @@ def gen_ctag(seq, tag)
op=>opnext = new_op op=>opnext = new_op
op = op=>opnext op = op=>opnext
fin fin
op->opcode = INVALID_CODE
op->opgroup = CODETAG_GROUP op->opgroup = CODETAG_GROUP
op=>optag = tag op=>optag = tag
return seq return seq

View File

@ -133,7 +133,7 @@ def crunch_seq(seq, pass)
fin fin
break break
is CONST_CODE // Collapse constant operation is CONST_CODE // Collapse constant operation
nextopnext = nextop->nextop nextopnext = nextop=>opnext
if nextopnext if nextopnext
when nextopnext->opcode when nextopnext->opcode
is MUL_CODE is MUL_CODE

View File

@ -79,6 +79,10 @@ const BRNCH_CODE = $50
// //
const CODETAG_GROUP = $06 const CODETAG_GROUP = $06
// //
// Invalid code
//
const INVALID_CODE = $FF
//
// Code sequence op // Code sequence op
// //
struc t_opseq struc t_opseq

View File

@ -1123,7 +1123,7 @@ def cmdmode#0
word cmdptr word cmdptr
clrscrn clrscrn
puts("PLASMA Editor, Version 1.01\n") puts("PLASMA Editor, Version 1.1\n")
while not exit while not exit
puts(@filename) puts(@filename)
cmdptr = gets($BA) cmdptr = gets($BA)

View File

@ -26,28 +26,24 @@
// fin // fin
// return FALSE // return FALSE
//end //end
def keymatch //def keymatch
byte i, keypos // byte i, keypos
word chrptr // word chrptr
//
keypos = 0 // keypos = 0
while keywrds[keypos] < tknlen // while keywrds[keypos] < tknlen
keypos = keypos + keywrds[keypos] + 2 // keypos = keypos + keywrds[keypos] + 2
loop // loop
chrptr = tknptr - 1 // chrptr = tknptr - 1
while keywrds[keypos] == tknlen // while keywrds[keypos] == tknlen
for i = 1 to tknlen // i = 1; while i <= tknlen and ^(chrptr + i) == keywrds[keypos + i]; i++; loop
if ^(chrptr + i) <> keywrds[keypos + i] // if i > tknlen
break // return keywrds[keypos + keywrds[keypos] + 1]
fin // fin
next // keypos = keypos + keywrds[keypos] + 2
if i > tknlen // loop
return keywrds[keypos + keywrds[keypos] + 1] // return ID_TKN
fin //end
keypos = keypos + keywrds[keypos] + 2
loop
return ID_TKN
end
def scannum def scannum
word num word num
num = 0 num = 0
@ -84,23 +80,20 @@ def scan
scanptr++ scanptr++
loop loop
tknptr = scanptr tknptr = scanptr
scanchr = toupper(^scanptr) scanchr, scanptr, token = scanid(scanptr, @keywrds) //scanchr = toupper(^scanptr)
// //
// Scan for token based on first character // Scan for token based on first character
// //
//if isalpha(scanchr) if token //if isalpha(scanchr)
if (scanchr >= 'A' and scanchr <= 'Z') or (scanchr == '_')
// //
// ID, either variable name or reserved word // ID, either variable name or reserved word
// //
repeat //repeat
^scanptr = scanchr // ^scanptr = scanchr
scanptr++ // scanptr++
scanchr = toupper(^scanptr) // scanchr = toupper(^scanptr)
//until not isalphanum(scanchr) //until not isalphanum(scanchr)
until not ((scanchr >= 'A' and scanchr <= 'Z') or (scanchr >= '0' and scanchr <= '9' ) or (scanchr == '_'))
tknlen = scanptr - tknptr tknlen = scanptr - tknptr
token = keymatch
elsif scanchr >= '0' and scanchr <= '9' // isnum() elsif scanchr >= '0' and scanchr <= '9' // isnum()
// //
// Decimal constant // Decimal constant

View File

@ -342,6 +342,106 @@ const ERR_SYNTAX = $8000
// //
//===================================== //=====================================
//
// Lexical scanner helper for keyword/IDs
//
asm scanid(scanptr, keywrds)#3
!SOURCE "vmsrc/plvmzp.inc"
LDA ESTKL,X
STA DSTL
LDA ESTKH,X
STA DSTH
LDA ESTKL+1,X
STA ESTKL,X ; COPY OUTPUT SCANPTR
STA SRCL
LDA ESTKH+1,X
STA ESTKH,X
STA SRCH
DEX
LDA #$00
STA ESTKL,X ; CLEAR OUTPUT TOKEN
STA ESTKH,X
STA ESTKH+2,X ; CLEAR MSB OF SCANCHR
TAY
LDA (SRC),Y
AND #$7F
CMP #'a'
BCC +
CMP #'z'+1
BCS +
SBC #$1F
STA (SRC),Y
+ STA ESTKL+2,X ; SET SCANCHR
CMP #'_'
BEQ +
CMP #'A'
BCC SCANEX
CMP #'Z'+1
BCS SCANEX
+ LDA #$D6 ; ID_TKN
STA ESTKL,X ; SET OUTPUT TOKEN = ID_TKN
SCANID INY
LDA (SRC),Y
AND #$7F
BEQ ++
CMP #'a'
BCC +
CMP #'z'+1
BCS ++
SBC #$1F
STA (SRC),Y ; COPY UPPERCASE CHAR BACK TO ^SCANPTR
BNE SCANID
+ CMP #'_'
BEQ SCANID
CMP #'0'
BCC ++
CMP #'9'+1
BCC SCANID
CMP #'A'
BCC ++
CMP #'Z'+1
BCC SCANID
++ STY TMPL
TYA
LDY #$00
CLC
ADC SRCL
STA ESTKL+1,X ; UPDATE SCANPTR
BCC MATCHLEN
INC ESTKH+1,X
MATCHLEN LDA (DST),Y
CMP TMPL
BCS +
ADC #$02
ADC DSTL
STA DSTL
BCC MATCHLEN
INC DSTH
BNE MATCHLEN
+ BNE SCANEX ; NO KEY MATCH
TAY
DEY
INC DSTL
BNE MATCHKEY
INC DSTH
MATCHKEY LDA (SRC),Y
CMP (DST),Y
BNE NEXTKEY
DEY
BPL MATCHKEY
LDY TMPL
LDA (DST),Y
STA ESTKL,X ; SET OUTPUT TOKEN
SCANEX RTS
NEXTKEY LDY #$00
LDA TMPL
SEC
ADC DSTL
STA DSTL
BCC MATCHLEN
INC DSTH
BNE MATCHLEN
end
// //
// Handy functions // Handy functions
// //
@ -411,7 +511,7 @@ include "toolsrc/parse.pla"
// //
// Look at command line arguments and compile module // Look at command line arguments and compile module
// //
puts("PLASMA Compiler, Version 1.02\n") puts("PLASMA Compiler, Version 1.1\n")
arg = argNext(argFirst) arg = argNext(argFirst)
if ^arg and ^(arg + 1) == '-' if ^arg and ^(arg + 1) == '-'
opt = arg + 2 opt = arg + 2

View File

@ -40,7 +40,7 @@ predef sext(a)#1, divmod(a,b)#2, execmod(modfile)#1
// //
// Exported CMDSYS table // Exported CMDSYS table
// //
word version = $0100 // 01.00 word version = $0110 // 01.10
word syspath word syspath
word syscmdln word syscmdln
word = @execmod word = @execmod

View File

@ -38,7 +38,7 @@ predef execmod(modfile)#1
// //
// Exported CMDSYS table // Exported CMDSYS table
// //
word version = $0101 // 01.01 word version = $0110 // 01.10
word syspath word syspath
word syscmdln word syscmdln
word = @execmod word = @execmod

View File

@ -147,7 +147,7 @@ DIVMOD JSR _DIV
STA ESTKL,X STA ESTKL,X
LDA TMPH ; REMNDRH LDA TMPH ; REMNDRH
STA ESTKH,X STA ESTKH,X
LDA DVSIGN ; REMAINDER IS SIGN OF DIVIDEND ASL DVSIGN ; REMAINDER IS SIGN OF DIVIDEND
BMI NEG BMI NEG
JMP NEXTOP JMP NEXTOP
;* ;*
@ -171,21 +171,20 @@ _DIV STY IPY
LDA #$00 LDA #$00
STA TMPL ; REMNDRL STA TMPL ; REMNDRL
STA TMPH ; REMNDRH STA TMPH ; REMNDRH
LDA ESTKH,X
AND #$80
STA DVSIGN STA DVSIGN
BPL + LDA ESTKH+1,X
JSR _NEG
INC DVSIGN
+ LDA ESTKH+1,X
BPL + BPL +
INX INX
JSR _NEG JSR _NEG
DEX DEX
INC DVSIGN LDA #$81
BNE _DIV1 STA DVSIGN
+ ORA ESTKL+1,X ; DVDNDL + ORA ESTKL+1,X ; DVDNDL
BEQ _DIVEX BEQ _DIVEX
LDA ESTKH,X
BPL _DIV1
JSR _NEG
INC DVSIGN
_DIV1 ASL ESTKL+1,X ; DVDNDL _DIV1 ASL ESTKL+1,X ; DVDNDL
ROL ESTKH+1,X ; DVDNDH ROL ESTKH+1,X ; DVDNDH
DEY DEY

View File

@ -489,21 +489,20 @@ _DIV STY IPY
LDA #$00 LDA #$00
STA TMPL ; REMNDRL STA TMPL ; REMNDRL
STA TMPH ; REMNDRH STA TMPH ; REMNDRH
LDA ESTKH,X
AND #$80
STA DVSIGN STA DVSIGN
BPL + LDA ESTKH+1,X
JSR _NEG
INC DVSIGN
+ LDA ESTKH+1,X
BPL + BPL +
INX INX
JSR _NEG JSR _NEG
DEX DEX
INC DVSIGN LDA #$81
BNE _DIV1 STA DVSIGN
+ ORA ESTKL+1,X ; DVDNDL + ORA ESTKL+1,X ; DVDNDL
BEQ _DIVEX BEQ _DIVEX
LDA ESTKH,X
BPL _DIV1
JSR _NEG
INC DVSIGN
_DIV1 ASL ESTKL+1,X ; DVDNDL _DIV1 ASL ESTKL+1,X ; DVDNDL
ROL ESTKH+1,X ; DVDNDH ROL ESTKH+1,X ; DVDNDH
DEY DEY
@ -568,7 +567,7 @@ DIVMOD JSR _DIV
STA ESTKL,X STA ESTKL,X
LDA TMPH ; REMNDRH LDA TMPH ; REMNDRH
STA ESTKH,X STA ESTKH,X
LDA DVSIGN ; REMAINDER IS SIGN OF DIVIDEND ASL DVSIGN ; REMAINDER IS SIGN OF DIVIDEND
BMI NEG BMI NEG
JMP NEXTOP JMP NEXTOP
;* ;*

View File

@ -193,21 +193,20 @@ _DIV STY IPY
LDA #$00 LDA #$00
STA TMPL ; REMNDRL STA TMPL ; REMNDRL
STA TMPH ; REMNDRH STA TMPH ; REMNDRH
LDA ESTKH,X
AND #$80
STA DVSIGN STA DVSIGN
BPL + LDA ESTKH+1,X
JSR _NEG
INC DVSIGN
+ LDA ESTKH+1,X
BPL + BPL +
INX INX
JSR _NEG JSR _NEG
DEX DEX
INC DVSIGN LDA #$81
BNE _DIV1 STA DVSIGN
+ ORA ESTKL+1,X ; DVDNDL + ORA ESTKL+1,X ; DVDNDL
BEQ _DIVEX BEQ _DIVEX
LDA ESTKH,X
BPL _DIV1
JSR _NEG
INC DVSIGN
_DIV1 ASL ESTKL+1,X ; DVDNDL _DIV1 ASL ESTKL+1,X ; DVDNDL
ROL ESTKH+1,X ; DVDNDH ROL ESTKH+1,X ; DVDNDH
DEY DEY
@ -296,7 +295,7 @@ DIVMOD JSR _DIV
STA ESTKL,X STA ESTKL,X
LDA TMPH ; REMNDRH LDA TMPH ; REMNDRH
STA ESTKH,X STA ESTKH,X
LDA DVSIGN ; REMAINDER IS SIGN OF DIVIDEND ASL DVSIGN ; REMAINDER IS SIGN OF DIVIDEND
BMI NEG BMI NEG
JMP NEXTOP JMP NEXTOP
;* ;*

View File

@ -543,19 +543,20 @@ _MULLP ASL
_DIV STY IPY _DIV STY IPY
LDY #$11 ; #BITS+1 LDY #$11 ; #BITS+1
LDX #$00 LDX #$00
LDA TOS+2,S ; WE JSR'ED HERE SO OFFSET ACCORDINGLY LDA NOS+2,S ; WE JSR'ED HERE SO OFFSET ACCORDINGLY
BEQ _DIVEX
BPL + BPL +
LDX #$81 LDX #$81
EOR #$FFFF EOR #$FFFF
INC INC
STA TOS+2,S + STA TMP ; NOS,S
+ LDA NOS+2,S LDA TOS+2,S
BPL + BPL +
INX INX
EOR #$FFFF EOR #$FFFF
INC INC
+ STA TMP ; NOS,S STA TOS+2,S
BEQ _DIVEX + LDA TMP
_DIV1 ASL ; DVDND _DIV1 ASL ; DVDND
DEY DEY
BCC _DIV1 BCC _DIV1

View File

@ -29,7 +29,7 @@ predef execmod(modfile)#1
// //
// Exported CMDSYS table // Exported CMDSYS table
// //
word version = $0102 // 01.02 word version = $0110 // 01.10
word syspath word syspath
word cmdlnptr word cmdlnptr
word = @execmod word = @execmod

View File

@ -30,7 +30,7 @@ predef sext(a)#1, divmod(a,b)#2, execmod(modfile)#1
// //
// Exported CMDSYS table // Exported CMDSYS table
// //
word version = $0100 // 01.00 word version = $0110 // 01.10
word syspath word syspath
word syscmdln word syscmdln
word = @execmod word = @execmod

View File

@ -147,7 +147,7 @@ DIVMOD JSR _DIV
STA ESTKL,X STA ESTKL,X
LDA TMPH ; REMNDRH LDA TMPH ; REMNDRH
STA ESTKH,X STA ESTKH,X
LDA DVSIGN ; REMAINDER IS SIGN OF DIVIDEND ASL DVSIGN ; REMAINDER IS SIGN OF DIVIDEND
BMI NEG BMI NEG
JMP NEXTOP JMP NEXTOP
;* ;*
@ -171,21 +171,20 @@ _DIV STY IPY
LDA #$00 LDA #$00
STA TMPL ; REMNDRL STA TMPL ; REMNDRL
STA TMPH ; REMNDRH STA TMPH ; REMNDRH
LDA ESTKH,X
AND #$80
STA DVSIGN STA DVSIGN
BPL + LDA ESTKH+1,X
JSR _NEG
INC DVSIGN
+ LDA ESTKH+1,X
BPL + BPL +
INX INX
JSR _NEG JSR _NEG
DEX DEX
INC DVSIGN LDA #$81
BNE _DIV1 STA DVSIGN
+ ORA ESTKL+1,X ; DVDNDL + ORA ESTKL+1,X ; DVDNDL
BEQ _DIVEX BEQ _DIVEX
LDA ESTKH,X
BPL _DIV1
JSR _NEG
INC DVSIGN
_DIV1 ASL ESTKL+1,X ; DVDNDL _DIV1 ASL ESTKL+1,X ; DVDNDL
ROL ESTKH+1,X ; DVDNDH ROL ESTKH+1,X ; DVDNDH
DEY DEY

View File

@ -455,6 +455,7 @@ void interp(code *ip);
void call(uword pc) void call(uword pc)
{ {
unsigned int i, s; unsigned int i, s;
int a, b;
char c, sz[64]; char c, sz[64];
if (show_state) if (show_state)
@ -508,6 +509,12 @@ void call(uword pc)
mem_data[0x1FF] = i; mem_data[0x1FF] = i;
PUSH(0x1FF); PUSH(0x1FF);
break; break;
case 24: // LIBRARY CMDSYS::DIVMOD
a = POP;
b = POP;
PUSH(b / a);
PUSH(b % a);
break;
default: default:
printf("\nUnimplemented call code:$%02X\n", mem_data[pc - 1]); printf("\nUnimplemented call code:$%02X\n", mem_data[pc - 1]);
exit(1); exit(1);