Commit 502e0839 by Jessica Hawkwell

Adding kasm tool documentation.

1 parent 9372b32a
Pipeline #217 passed
in 1 minute 11 seconds
# K Architecture
_Short for "Kitty" :smiley_cat:_
---
_Short for "Kitty"_ :smiley_cat:
The K architecture features a 16-bit CPU with 16-bit memory addressing, and a 32-bit math co-processor.
The instruction set is relatively simple, for details, see [Writing Kasm](doc/kasm/writing.md).
# Building the Emulator
---
Building the emulator is a fairly straightforward process. Just grab the source and build it.
## Required Software
......@@ -48,14 +45,14 @@ mvn dependency:copy-dependencies
```
This will place the runtime dependencies into the appropriate folder. You can now run the emulator.
```
java -jar target/kcpu-1.0-SNAPSHOT.jar
./kcpu.sh
```
You probably won't see anything and that's okay. Add the `-v` or `--verbose` command line options to watch the
processor executing instructions.
```
java -jar target/kcpu-1.0-SNAPSHOT.jar -v
./kcpu.sh -v
```
There are some other options which may be useful:
```
java -jar target/kcpu-1.0-SNAPSHOT.jar -h
./kcpu.sh -h
```
# Using Kasm
The Kasm assembler is included as part of the Kcpu project. No additional build steps are required to use Kasm.
The assembler can be invoked with a simple command line argument:
```
java -jar target/kcpu-1.0-SNAPSHOT.jar -kasm
```
To view the available command line arguments:
```
./kasm.sh -h
```
Which will display:
```
usage: kasm [options] [kasm ...]
-b,--base <addr> Program's base address. Emitted code will assume it
is loaded to this address.
-c,--cpu Displays suppoted CPU opcodes
-h,--help Shows this help.
--kasm This option is ignored.
-m,--mcu Displays suported MCU opcodes.
-o,--output <file> Filename to use for building a single output file.
-v,--verbose Verbose output.
Non-KASM files may be ignored.
```
# Compiling Kasm Programs
After writing a Kasm program, it is necessary to compile it so it can be run in Kcpu.
The simplest way to do this is to just invoke Kasm and tell it which files to compile.
```
./kasm.sh test.kasm
```
You can use the `-v` or `--verbose` options for verbose output. It will display the names of each input and output file,
as well as display a textual representation of the compiled code as it moves along.
```
./kasm.sh -v test.kasm
```
Will display something similar to this:
```
Input : /Users/jlhawkwell/Projects/kcpu/test.kasm
Output: /Users/jlhawkwell/Projects/kcpu/test.kc
[ MOVS] 1100 : 0702 -> 0000 0200
[ ADD] 0100 : 0102 -> 0000 1000
[ ADD] 0100 : 0102 -> 0200 0100
[ MOVS] 1100 : 0702 -> 0000 0200
[ JDL] 28ff : 0103 -> 0000 0002 2a00
[ DEVA] 00ff : 0001 -> 0000
[ DEVA] 00ff : 0001 -> 0100
[ GPC] 1bff : 0000 ->
[ GPC] 1bff : 0201 -> 0004
```
The columns are, in the following order:
`[Instruction] opcode : reference -> arguments`
The `reference` column is automatically generated. The reference value tells the processor how many arguments there are
and how to store or load each one. It is directly correlated to the argument types specified in the assembly code.
By default, Kasm will produce exactly one binary for each input source file. Optionally, you can have all source files
built into a single binary by using the `-o` option.
```
./kasm.sh -o output.kc rom1.kasm rom2.kasm rom3.kasm
```
This command will compile the source files in the specified order and write out all the machine code to `output.kc`
# Writing Kasm Programs
Writing Kasm programs is a fairly involved process, as assembly language(s) generally are. For information on writing
Kasm programs, see [Writing Kasm](writing.md)
#!/bin/sh
java -jar target/kcpu-1.0-SNAPSHOT.jar -kasm $@
#!/bin/sh
java -jar target/kcpu-1.0-SNAPSHOT.jar $@
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!