Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/newcomb-luke/brisc-assembler
An assembler for the BRISC assembly language.
https://github.com/newcomb-luke/brisc-assembler
Last synced: about 1 month ago
JSON representation
An assembler for the BRISC assembly language.
- Host: GitHub
- URL: https://github.com/newcomb-luke/brisc-assembler
- Owner: newcomb-luke
- License: gpl-3.0
- Created: 2023-11-13T19:34:41.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-14T17:21:25.000Z (about 1 year ago)
- Last Synced: 2023-12-14T18:51:38.928Z (about 1 year ago)
- Language: Rust
- Homepage:
- Size: 40 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# brisc-assembler
An assembler for the BRISC assembly language.
## Build Instructions
With Rust installed, simply use cargo to build the project:
```bash
cd brisc-assembler/
cargo build --release
```## Usage Instructions
This will assemble the file **prog.basm** into **prog.bin**:
```bash
brisc-assembler prog.basm
```These will both assemble the file **prog.basm** into **output.bin**:
```bash
brisc-assembler prog.basm -o output.binbrisc-assembler prog.basm --output-path output.bin
```Display help:
```bash
brisc-assembler --help
```## Language Reference
### Notation
Any Register - `rX`
Label - ``
Integer - ``### Math Instructions
#### Add
```
add rX, rx
```
#### Subtract
```
sub rX, rX
```
#### Bitwise And
```
and rX, rX
```
#### Bitwise Or
```
or rX, rX
```
#### Bitwise Exclusive Or
```
xor rX, rX
```
#### Bitwise Invert
```
inv rX
```
#### Bitwise Shift Right
```
sr rX, rX
```
#### Bitwise Shift Left
```
sl rX, rX
```### Memory Instructions
#### Load Immediate Value
```
ldi rX,
```### I/O Instructions
#### Input from Source
```
in rX,
```#### Output to Sink
```
out rX,
```#### Sources (Input)
| Name | Value |
|----------|-------|
| Switches | 0 |
| BTNC | 1 |
| BTNU | 2 |
| BTNL | 3 |
| BTNR | 4 |
| BTND | 5 |
| COUNTER | 6 |#### Sinks (Output)
| Name | Value |
|-----------------|-------|
| 7 Segment Right | 0 |
| 7 Segment Left | 1 |### Jump Instructions
#### Jump if Zero
```
jz rX,
jz rX,
```#### Jump if Less Than
```
jlt rX,
jlt rX,
```#### Jump Always
```
j
j
```### Labels
For loop example:
```
ldi r0, 0 ; Our counter 'i'
ldi r1, 1 ; A register just to hold our increment, 1for_loop:
ldi r2, 5 ; Our maximum value, 5; Do something here you want to happen 5 times
sub r2, r0 ; r2 = r2 - r0
jz r2, for_loop_end ; If (5 - i) == 0, break the loop
add r0, r1 ; i++
j for_loop ; Loop again
foor_loop_end:
nop ; Continue with the rest of the program
```