lawless-legends/Docs/Tutorials/PLASMA/User Manual.md

39 lines
1.8 KiB
Markdown
Raw Normal View History

2014-05-16 05:45:21 +00:00
# PLASMA Programming Manual
## ( Proto Language AsSeMbler for Apple)
## Introduction
2014-05-16 05:45:21 +00:00
PLASMA is a medium level programming language for the 8 bit 6502 processor. Historically, there were simple languages developed in the early history of computers that improved on the tedium of assembly language programming while still being low level enough for system coding. Languages like B, FORTH, and PLASMA fall into this category. The following will take you through the process of writing, building and running a PLASMA module.
### Obligatory 'Hello world'
To start things off, here is the standard introductory program:
```
import STDLIB
2014-05-16 05:46:21 +00:00
predef puts
2014-05-16 05:45:21 +00:00
end
byte hello[] = "Hello, world.\n"
puts(@hello)
done
```
2014-05-16 06:03:46 +00:00
Three tools are required to build and run this program: **plasm**, **acme**, and **plvm**. The PLASMA compiler, **plasm**, will convert the PLASMA source code (usually with an extension on .pla) into an assembly language source file. **acme**, the portable 6502 assembler will convert the assembly source into a binary ready for loading. To execute the module, the PLASMA portable VM, **plvm**, can load and interpret the bytecode. The same binary can be loaded onto the target platform and run there with the appropriate VM. On Linux/Unix from the lawless-legends/PLASMA/src, the steps would be entered as:
2014-05-16 05:45:21 +00:00
```
./plasm -AM < hello.pla > hello.a
acme --setpc 4096 -o HELLO.REL hello.a
./plvm HELLO.REL
```
The computer will respond with:
```
Load module HELLO.REL
Hello, world.
```
2014-05-16 06:03:46 +00:00
A couple of things to note: **plasm** only accepts input from stdin and output to stdout. To build acme compatible module source, tha '-AM' flags must be passed in. The **acme** assembler needs the --setpc 4096 to assemble the module at the proper address, and the -o option sets the output file.
2014-05-16 05:45:21 +00:00