mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-12-26 04:32:05 +00:00
Update comment and multiple statements
Update comment symbol to "//" and allow multiple statements per line with ";"
This commit is contained in:
parent
1740e93d11
commit
d62f499c31
@ -92,18 +92,18 @@ The PLASMA low level operations are defined as:
|
||||
|
||||
##PLASMA Compiler/Assembler
|
||||
|
||||
Although the low-level operations could easily by coded by hand, they were chosen to be an easy target for a simple compiler. Think along the lines of an advanced assembler or stripped down C compiler ( C--). Taking concepts from BASIC, Pascal, C and assembler, the PLASMA compiler is simple yet expressive. The syntax is line oriented; there is no statement delimiter except newline.
|
||||
Although the low-level operations could easily by coded by hand, they were chosen to be an easy target for a simple compiler. Think along the lines of an advanced assembler or stripped down C compiler ( C--). Taking concepts from BASIC, Pascal, C and assembler, the PLASMA compiler is simple yet expressive. The syntax is line oriented. However, the ';' character can seperate multiple statements on a single line. It is generally considered bad form to have multiple statements per line unless they are very short.
|
||||
|
||||
Comments are allowed throughout the source, starting with the ‘;’ character. The rest of the line is ignored.
|
||||
Comments are allowed throughout the source, starting with the ‘//’ symbol. The rest of the line is ignored.
|
||||
|
||||
```
|
||||
; Data and text buffer constants
|
||||
// Data and text buffer constants
|
||||
```
|
||||
|
||||
Hexadecimal constants are preceded with a ‘$’ to identify them as such.
|
||||
|
||||
```
|
||||
$C030 ; Speaker address
|
||||
$C030 // Speaker address
|
||||
```
|
||||
|
||||
###Constants, Variables and Functions
|
||||
@ -111,27 +111,27 @@ Hexadecimal constants are preceded with a ‘$’ to identify them as such.
|
||||
The source code of a PLASMA module first defines imports, constants, variables and data. Constants must be initialized with a value. Variables can have sizes associated with them to declare storage space. Data can be declared with or without a variable name associated with it. Arrays, tables, strings and any predeclared data can be created and accessed in multiple ways.
|
||||
|
||||
```
|
||||
;
|
||||
; Import standard library functions.
|
||||
;
|
||||
//
|
||||
// Import standard library functions.
|
||||
//
|
||||
import stdlib
|
||||
predef putc, puts, getc, gets, cls, memcpy, memset, memclr
|
||||
end
|
||||
;
|
||||
; Constants used for hardware and flags
|
||||
;
|
||||
//
|
||||
// Constants used for hardware and flags
|
||||
//
|
||||
const speaker = $C030
|
||||
const changed = 1
|
||||
const insmode = 2
|
||||
;
|
||||
; Array declaration of screen row addresses
|
||||
;
|
||||
//
|
||||
// Array declaration of screen row addresses
|
||||
//
|
||||
word txtscrn[] = $0400,$0480,$0500,$0580,$0600,$0680,$0700,$0780
|
||||
word = $0428,$04A8,$0528,$05A8,$0628,$06A8,$0728,$07A8
|
||||
word = $0450,$04D0,$0550,$05D0,$0650,$06D0,$0750,$07D0
|
||||
;
|
||||
; Misc global variables
|
||||
;
|
||||
//
|
||||
// Misc global variables
|
||||
//
|
||||
byte flags = 0
|
||||
word numlines = 0
|
||||
byte cursx, cursy
|
||||
@ -143,9 +143,9 @@ Variables can have optional brackets; empty brackets don’t reserve any space f
|
||||
Strings are defined like Pascal strings, a length byte followed by the string characters so they can be a maximum of 255 characters long. Strings can only appear in the variable definitions of a module. String constants can’t be used in expressions or statements.
|
||||
|
||||
```
|
||||
;
|
||||
; An initialized string of 64 characters
|
||||
;
|
||||
//
|
||||
// An initialized string of 64 characters
|
||||
//
|
||||
byte txtfile[64] = "UNTITLED"
|
||||
```
|
||||
|
||||
@ -195,7 +195,7 @@ Functions with parameters or expressions to be used as a function address to cal
|
||||
word keyin
|
||||
byte key
|
||||
|
||||
keyin = @keyin2plus ; address-of keyin2plus function
|
||||
keyin = @keyin2plus // address-of keyin2plus function
|
||||
key = keyin()
|
||||
```
|
||||
|
||||
@ -206,7 +206,7 @@ Expressions are algebraic. Data is free-form, but all operations on the evaluat
|
||||
```
|
||||
const speaker=$C030
|
||||
|
||||
^speaker ; click speaker
|
||||
^speaker // click speaker
|
||||
close(refnum)
|
||||
```
|
||||
|
||||
@ -257,11 +257,11 @@ Control structures affect the flow of control through the program. There are co
|
||||
```
|
||||
if ^pushbttn3 < 128
|
||||
if key == $C0
|
||||
key = $D0 ; P
|
||||
key = $D0 // P
|
||||
elsif key == $DD
|
||||
key = $CD ; M
|
||||
key = $CD // M
|
||||
elsif key == $DE
|
||||
key = $CE ; N
|
||||
key = $CE // N
|
||||
fin
|
||||
else
|
||||
key = key | $E0
|
||||
@ -346,7 +346,7 @@ romcall(aReg, xReg, yReg, statusReg, addr) returns a pointer to a four byte stru
|
||||
const xreg = 1
|
||||
const getlin = $FD6A
|
||||
|
||||
numchars = (romcall(0, 0, 0, 0, getlin)).xreg ; return char count in X reg
|
||||
numchars = (romcall(0, 0, 0, 0, getlin)).xreg // return char count in X reg
|
||||
```
|
||||
|
||||
syscall(cmd, params) calls ProDOS, returning the status value.
|
||||
@ -367,8 +367,8 @@ syscall(cmd, params) calls ProDOS, returning the status value.
|
||||
putc(char), puts(string), home, gotoxy(x,y), getc() and gets() are other handy utility routines for interacting with the console.
|
||||
|
||||
```
|
||||
putc('.')
|
||||
byte okstr[] = "OK"
|
||||
putc('.')
|
||||
puts(@okstr)
|
||||
```
|
||||
|
||||
@ -376,7 +376,7 @@ memset(addr, len, val) will fill memory with a 16 bit value. memcpy(dstaddr, sr
|
||||
|
||||
```
|
||||
byte nullstr[] = ""
|
||||
memset(strlinbuf, maxfill * 2, @nullstr) ; fill line buff with pointer to null string
|
||||
memset(strlinbuf, maxfill * 2, @nullstr) // fill line buff with pointer to null string
|
||||
memcpy(scrnptr, strptr + ofst + 1, numchars)
|
||||
```
|
||||
|
||||
@ -384,7 +384,7 @@ memset(addr, len, val) will fill memory with a 16 bit value. memcpy(dstaddr, sr
|
||||
###The Original PLASMA
|
||||
The original design concept was to create an efficient, flexible, and expressive environment for building applications directly on the Apple II. Choosing a stack based architecture was easy after much experience with other stack based implementations. It also makes the compiler simple to implement. The first take on the stack architecture was to make it a very strict stack architecture in that everything had to be on the stack. The only opcode with operands was the CONSTANT opcode. This allowed for a very small bytecode interpreter and a very easy compile target. However, only when adding an opcode with operands that would greatly improved performance, native code generation or code size was it done. The opcode table grew slowly over time but still retains a small runtime interpreter with good native code density.
|
||||
|
||||
The VM was constructed such that code generation could ouput native 6502 code, threaded code into the opcode functions, or interpreted bytecodes. This gave a level of control over speed vs memory.
|
||||
The VM was constructed such that code generation could output native 6502 code, threaded code into the opcode functions, or interpreted bytecodes. This gave a level of control over speed vs memory.
|
||||
|
||||
###The Lawless Legends PLASMA
|
||||
This version of PLASMA has dispensed with the native/threaded/bytecode code generation from the original version to focus on code density and the ability to interpret bytecode from AUX memory, should it be available. By focussing on the bytecode interpreter, certain optimizations were implemented that weren't posssible when allowing for threaded/native code; the interpreted bytecode is now about the same performance as the directly threaded code.
|
||||
|
Loading…
Reference in New Issue
Block a user