1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-07-05 04: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!
[Download and read the Release Notes](https://github.com/dschmenk/PLASMA/blob/master/doc/Version%201.0.md)
# 3/13/2018 PLASMA 1.1 Available!
[Download and read the Release Notes](https://github.com/dschmenk/PLASMA/blob/master/doc/Version%201.1.md)
# 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 ///.
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):
@ -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...
# 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
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)
$(PLVMZP_APL): FORCE
-mkdir rel
-mkdir rel/apple
-rm vmsrc/plvmzp.inc
-mkdir -p rel
-mkdir -p rel/apple
-rm -f vmsrc/plvmzp.inc
-ln -s apple/plvmzp.inc vmsrc/plvmzp.inc
$(PLVMZP_C64): FORCE
-mkdir rel
-mkdir rel/c64
-rm vmsrc/plvmzp.inc
-mkdir -p rel
-mkdir -p rel/c64
-rm -f vmsrc/plvmzp.inc
-ln -s c64/plvmzp.inc vmsrc/plvmzp.inc
FORCE:

View File

@ -85,7 +85,7 @@ def vals123#3
return 1, 2, 3
end
export def main(range)#0
byte a, b, c
word a, b, c
word lambda
a = 10
@ -127,6 +127,14 @@ export def main(range)#0
drop, b, drop = vals123
drop, drop, c = vals123
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
def dummy(zz)#2

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -543,19 +543,20 @@ _MULLP ASL
_DIV STY IPY
LDY #$11 ; #BITS+1
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 +
LDX #$81
EOR #$FFFF
INC
STA TOS+2,S
+ LDA NOS+2,S
+ STA TMP ; NOS,S
LDA TOS+2,S
BPL +
INX
EOR #$FFFF
INC
+ STA TMP ; NOS,S
BEQ _DIVEX
STA TOS+2,S
+ LDA TMP
_DIV1 ASL ; DVDND
DEY
BCC _DIV1

View File

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

View File

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

View File

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

View File

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