Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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.bin

brisc-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, 1

for_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
```