diff --git a/PLASMA-BLD1.PO b/PLASMA-BLD1.PO index bb1d254..ed98e66 100644 Binary files a/PLASMA-BLD1.PO and b/PLASMA-BLD1.PO differ diff --git a/PLASMA-SOS1.PO b/PLASMA-SOS1.PO index 6c88290..a574b69 100644 Binary files a/PLASMA-SOS1.PO and b/PLASMA-SOS1.PO differ diff --git a/PLASMA-SYS1.PO b/PLASMA-SYS1.PO index 0437ae0..b198a9c 100644 Binary files a/PLASMA-SYS1.PO and b/PLASMA-SYS1.PO differ diff --git a/README.md b/README.md index 50c3b66..f7c52dc 100755 --- a/README.md +++ b/README.md @@ -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 diff --git a/doc/Version 1.0.md b/doc/Version 1.1.md similarity index 96% rename from doc/Version 1.0.md rename to doc/Version 1.1.md index a24595c..a96201d 100644 --- a/doc/Version 1.0.md +++ b/doc/Version 1.1.md @@ -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: diff --git a/src/makefile b/src/makefile index d77eab5..ed475b1 100755 --- a/src/makefile +++ b/src/makefile @@ -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: diff --git a/src/samplesrc/test.pla b/src/samplesrc/test.pla index 915a0b5..a8a1c26 100755 --- a/src/samplesrc/test.pla +++ b/src/samplesrc/test.pla @@ -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 diff --git a/src/toolsrc/codegen.pla b/src/toolsrc/codegen.pla index 299fd2c..c51ab70 100644 --- a/src/toolsrc/codegen.pla +++ b/src/toolsrc/codegen.pla @@ -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 diff --git a/src/toolsrc/codeopt.pla b/src/toolsrc/codeopt.pla index c0481d8..d695d5b 100644 --- a/src/toolsrc/codeopt.pla +++ b/src/toolsrc/codeopt.pla @@ -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 diff --git a/src/toolsrc/codeseq.plh b/src/toolsrc/codeseq.plh index 6cc4cf3..899d642 100644 --- a/src/toolsrc/codeseq.plh +++ b/src/toolsrc/codeseq.plh @@ -79,6 +79,10 @@ const BRNCH_CODE = $50 // const CODETAG_GROUP = $06 // +// Invalid code +// +const INVALID_CODE = $FF +// // Code sequence op // struc t_opseq diff --git a/src/toolsrc/ed.pla b/src/toolsrc/ed.pla index 2a96be4..65f8f21 100755 --- a/src/toolsrc/ed.pla +++ b/src/toolsrc/ed.pla @@ -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) diff --git a/src/toolsrc/lex.pla b/src/toolsrc/lex.pla index 2a6474c..6d8f062 100644 --- a/src/toolsrc/lex.pla +++ b/src/toolsrc/lex.pla @@ -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 diff --git a/src/toolsrc/plasm.pla b/src/toolsrc/plasm.pla index 5da3dc6..c483a53 100644 --- a/src/toolsrc/plasm.pla +++ b/src/toolsrc/plasm.pla @@ -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 diff --git a/src/vmsrc/apple/a1cmd.pla b/src/vmsrc/apple/a1cmd.pla index 6ecf924..b93c896 100755 --- a/src/vmsrc/apple/a1cmd.pla +++ b/src/vmsrc/apple/a1cmd.pla @@ -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 diff --git a/src/vmsrc/apple/cmd.pla b/src/vmsrc/apple/cmd.pla index 68309fb..339b12c 100755 --- a/src/vmsrc/apple/cmd.pla +++ b/src/vmsrc/apple/cmd.pla @@ -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 diff --git a/src/vmsrc/apple/plvm01.s b/src/vmsrc/apple/plvm01.s index b391d3c..e6870b3 100644 --- a/src/vmsrc/apple/plvm01.s +++ b/src/vmsrc/apple/plvm01.s @@ -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 diff --git a/src/vmsrc/apple/plvm02.s b/src/vmsrc/apple/plvm02.s index 77d2d58..9e58eac 100755 --- a/src/vmsrc/apple/plvm02.s +++ b/src/vmsrc/apple/plvm02.s @@ -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 ;* diff --git a/src/vmsrc/apple/plvm03.s b/src/vmsrc/apple/plvm03.s index 40e8e64..824de0a 100755 --- a/src/vmsrc/apple/plvm03.s +++ b/src/vmsrc/apple/plvm03.s @@ -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 ;* diff --git a/src/vmsrc/apple/plvm802.s b/src/vmsrc/apple/plvm802.s index 5335412..18fca79 100644 --- a/src/vmsrc/apple/plvm802.s +++ b/src/vmsrc/apple/plvm802.s @@ -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 diff --git a/src/vmsrc/apple/soscmd.pla b/src/vmsrc/apple/soscmd.pla index 4afce58..d60bbc0 100755 --- a/src/vmsrc/apple/soscmd.pla +++ b/src/vmsrc/apple/soscmd.pla @@ -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 diff --git a/src/vmsrc/c64/cmd.pla b/src/vmsrc/c64/cmd.pla index d457d4f..e201988 100755 --- a/src/vmsrc/c64/cmd.pla +++ b/src/vmsrc/c64/cmd.pla @@ -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 diff --git a/src/vmsrc/c64/plvmc64.s b/src/vmsrc/c64/plvmc64.s index bfaa45c..02b5d03 100644 --- a/src/vmsrc/c64/plvmc64.s +++ b/src/vmsrc/c64/plvmc64.s @@ -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 diff --git a/src/vmsrc/plvm.c b/src/vmsrc/plvm.c index 5395c44..5379d9b 100755 --- a/src/vmsrc/plvm.c +++ b/src/vmsrc/plvm.c @@ -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);