Assembler
Software responsible for translating assembly language instructions into their corresponding binary code for execution on the FPGA board.
For example:
- Assembly
- Binary
; Prints "Hello Mom" to the top left of the screen and ends.
jmp main
hello: string "Hello Mom"
main:
loadn r0, #0 ; r0 = 0
loadn r1, #hello ; r1 = Pointer to the string to be printed.
loadn r2, #0 ; r2 = Index for the position on the screen
printLoop:
loadi r3, r1 ; Load the character to be printed
cmp r0, r3 ; and check if it's the terminal character.
jeq endLoop ; End if it is or,
outchar r3, r2 ; otherwise, print it and continue.
inc r1 ; Increment the pointer to the string.
inc r2 ; Increment the index for the position on the screen.
jmp printLoop
endLoop:
halt
-- Code generated by the assembler
WIDTH=16;
DEPTH=65536;
ADDRESS_RADIX=UNS;
DATA_RADIX=BIN;
CONTENT BEGIN
0:0000100000000000;
1:0000000000001100;
2:0000000001001000;
3:0000000001100101;
4:0000000001101100;
5:0000000001101100;
6:0000000001101111;
7:0000000000100000;
8:0000000001101101;
9:0000000001101111;
10:0000000001101101;
11:0000000000000000;
12:1110000000000000;
13:0000000000000000;
14:1110000010000000;
15:0000000000000010;
16:1110000100000000;
17:0000000000000000;
18:1111000110010000;
19:0101100000110000;
20:0000100001000000;
21:0000000000011011;
22:1100100110100000;
23:1001000010000000;
24:1001000100000000;
25:0000100000000000;
26:0000000000010010;
27:0011110000000000;
28:0000000000000000;
29:0000000000000000;
[...]
65533:0000000000000000;
65534:0000000000000000;
65535:0000000000000000;
END;
Installation
The assembler is available in two versions:
v1.0.0 stable
(recommended)v2.1.0 beta
To install them, run the following commands:
- stable
- beta
wget https://github.com/de-abreu/Processador-ICMC/raw/master/assembler/assembler-stable.zip
unzip assembler-stable.zip
cd stable
gcc *.c -o assembler
wget https://github.com/de-abreu/Processador-ICMC/raw/master/assembler/assembler-beta.zip
unzip assembler-beta.zip
cd beta
gcc *.c -o assembler
This will give you the executable assembler
. Take it to the directory where you are working, as convenient.
Usage
Without loss of generality, consider an assembly file game.asm
. If there are no syntax errors, running the following command will produce the binary file game.mif
:
- stable
- beta
./montador game.asm game.mif
./montador game.asm
Otherwise, if there are syntax errors, a corresponding error message will be issued.
TODO
- Find and detail the installation for Windows users
- Detail more assembler usage options