Skip to content
This repository has been archived by the owner on Dec 10, 2023. It is now read-only.

Commit

Permalink
add docs for bank usage
Browse files Browse the repository at this point in the history
  • Loading branch information
hlorenzi committed Mar 25, 2018
1 parent f63be1f commit 9cb248a
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 152 deletions.
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ This can be useful if you'd like to test out a new virtual machine's bytecode,
or even if you're eager to write programs for that new processor architecture
you just implemented in FPGA!

Check out the Releases section for pre-built binaries.

Check out the documentation for usage instructions:
- [Source File Format](/doc/src.md)
[Check out the Releases section](https://github.com/hlorenzi/customasm/releases)
for pre-built binaries.

[Check out the documentation](/doc/index.md) for usage instructions.

```
Usage: customasm [options] <file>
Expand All @@ -28,40 +28,40 @@ The idea is that, given the following file:
```
#cpudef
{
#align 8
load r1, {value} -> 8'0x11 @ value[7:0]
load r2, {value} -> 8'0x12 @ value[7:0]
load r3, {value} -> 8'0x13 @ value[7:0]
add r1, r2 -> 8'0x21
sub r3, {value} -> 8'0x33 @ value[7:0]
jnz {address} -> 8'0x40 @ address[15:0]
ret -> 8'0x50
#align 8
load r1, {value} -> 8'0x11 @ value[7:0]
load r2, {value} -> 8'0x12 @ value[7:0]
load r3, {value} -> 8'0x13 @ value[7:0]
add r1, r2 -> 8'0x21
sub r3, {value} -> 8'0x33 @ value[7:0]
jnz {address} -> 8'0x40 @ address[15:0]
ret -> 8'0x50
}
#addr 0x8000
#addr 0x100
multiply3x4:
load r1, 0
load r2, 3
load r3, 4
.loop:
add r1, r2
sub r3, 1
jnz .loop
ret
load r1, 0
load r2, 3
load r3, 4
.loop:
add r1, r2
sub r3, 1
jnz .loop
ret
```

...the assembler would use the `#cpudef` rules to convert the instructions into binary code:

```
8000: 11 00
8002: 12 03
8004: 13 04
8006: 21
8007: 33 01
8009: 40 80 06
800c: 50
0x0100: 11 00
0x0102: 12 03
0x0104: 13 04
0x0106: 21
0x0107: 33 01
0x0109: 40 01 06
0x010c: 50
```
1 change: 1 addition & 0 deletions doc/cpudef.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ Rule | Used as | Output
```
#cpudef
{
; you can have unusual counts of bits-per-byte too!
#align 3
lda #{value} -> 3'0b001 @ value[2:0]
Expand Down
Loading

0 comments on commit 9cb248a

Please sign in to comment.