Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c8d79bf67 | |||
| 95701058f1 | |||
| c7f52d9ce8 | |||
| 4bc49bb200 | |||
| bd07de84f9 | |||
| fb4883b840 |
68
README.md
68
README.md
@@ -16,26 +16,26 @@ There are 3 format types :
|
|||||||
|
|
||||||
```assembly
|
```assembly
|
||||||
operations:
|
operations:
|
||||||
add R1 R2 #1
|
ADD R1 R2 #1
|
||||||
sub R1 R2 R3
|
SUB R1 R2 R3
|
||||||
and R1 R2 #33
|
AND R1 R2 #33
|
||||||
xor R1 R2 R3
|
XOR R1 R2 R3
|
||||||
or R1 R2 R3
|
OR R1 R2 R3
|
||||||
sl R1 R2 R3
|
SL R1 R2 R3
|
||||||
sr R1 R2 R3
|
SR R1 R2 R3
|
||||||
mul R1 R2 R3
|
MUL R1 R2 R3
|
||||||
io:
|
io:
|
||||||
str R1 R2 R3
|
STR R1 R2 R3
|
||||||
ld R1 R2 R3
|
LD R1 R2 R3
|
||||||
sauts:
|
sauts:
|
||||||
jmp controle
|
JMP controle
|
||||||
jequ R1 R2 io
|
JEQU R1 R2 io
|
||||||
jneq R1 R2 sauts
|
JNEQ R1 R2 sauts
|
||||||
jsup R1 R2 operations
|
JSUP R1 R2 operations
|
||||||
jinf R1 R2 controle
|
JINF R1 R2 controle
|
||||||
controle:
|
controle:
|
||||||
call io
|
CALL io
|
||||||
ret
|
RET
|
||||||
```
|
```
|
||||||
|
|
||||||
Produces
|
Produces
|
||||||
@@ -49,20 +49,25 @@ Produces
|
|||||||
01010000 10100110 00000000 00000000
|
01010000 10100110 00000000 00000000
|
||||||
01100000 10100110 00000000 00000000
|
01100000 10100110 00000000 00000000
|
||||||
01110000 10100110 00000000 00000000
|
01110000 10100110 00000000 00000000
|
||||||
01000001 01001100 00000000 00000000
|
01000000 10100110 00000000 00000000
|
||||||
01010001 01001100 00000000 00000000
|
01010000 10100110 00000000 00000000
|
||||||
11000000 00000000 00000000 00010000
|
11000000 00000000 00000000 00010000
|
||||||
11010001 01000000 00000000 00001001
|
11010000 10100000 00000000 00001001
|
||||||
11100001 01000000 00000000 00001011
|
11100000 10100000 00000000 00001011
|
||||||
11110001 01000000 00000000 00000001
|
11110000 10100000 00000000 00000001
|
||||||
11000001 01000000 00000000 00010000
|
11000000 10100000 00000000 00010000
|
||||||
11010000 00000000 00000000 00001001
|
11010000 00000000 00000000 00001001
|
||||||
11100000 00000000 00000000 00000000
|
11100000 00000000 00000000 00000000
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Releases
|
||||||
|
|
||||||
|
Pre-compiled binaries are available in the [Release](https://git.ale-pri.com/Persson-dev/Assembleur/releases) section.
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
You should have [xmake](https://xmake.io) installed
|
If you wish to compile yourself, you must have [xmake](https://xmake.io) installed.
|
||||||
|
Instructions on how to install (and you should) [here](https://xmake.io/#/guide/installation)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
xmake
|
xmake
|
||||||
@@ -73,3 +78,18 @@ xmake
|
|||||||
```bash
|
```bash
|
||||||
xmake run Assembleur [args]
|
xmake run Assembleur [args]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Example :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
xmake run Assembleur test.asm -o memory
|
||||||
|
```
|
||||||
|
|
||||||
|
Parses the file `test.asm` and writes the output into the file `memory`
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
You can also add the binary to your path using
|
||||||
|
```bash
|
||||||
|
xmake install
|
||||||
|
```
|
||||||
@@ -80,11 +80,11 @@ std::uint32_t Assembleur::ParseOperationImmediate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::uint32_t Assembleur::ParseJump(Instruction a_Instruction, const std::string& a_Label) {
|
std::uint32_t Assembleur::ParseJump(Instruction a_Instruction, const std::string& a_Label) {
|
||||||
return IToInt(a_Instruction) | ParseLabel(a_Label);
|
return IToInt(a_Instruction) | ParseLabel(a_Label) & 0x3FFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint32_t Assembleur::ParseJump(Instruction a_Instruction, std::uint8_t a_R1, std::uint8_t a_R2, const std::string& a_Label) {
|
std::uint32_t Assembleur::ParseJump(Instruction a_Instruction, std::uint8_t a_R1, std::uint8_t a_R2, const std::string& a_Label) {
|
||||||
return IToInt(a_Instruction) | a_R1 << 24 | a_R2 << 21 | ParseLabel(a_Label);
|
return IToInt(a_Instruction) | a_R1 << 23 | a_R2 << 20 | ParseLabel(a_Label) & 0xFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint32_t Assembleur::ParseJump(Instruction a_Instruction) {
|
std::uint32_t Assembleur::ParseJump(Instruction a_Instruction) {
|
||||||
@@ -92,7 +92,7 @@ std::uint32_t Assembleur::ParseJump(Instruction a_Instruction) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::uint32_t Assembleur::ParseIO(Instruction a_Instruction, std::uint32_t a_R1, std::uint32_t a_R2, std::uint32_t a_R3) {
|
std::uint32_t Assembleur::ParseIO(Instruction a_Instruction, std::uint32_t a_R1, std::uint32_t a_R2, std::uint32_t a_R3) {
|
||||||
return IToInt(a_Instruction) | a_R1 << 24 | a_R2 << 21 | a_R3 << 18;
|
return IToInt(a_Instruction) | a_R1 << 23 | a_R2 << 20 | a_R3 << 17;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "IO.h"
|
#include "IO.h"
|
||||||
|
|
||||||
#define ASSEMBLEUR_VERSION "1.3"
|
#define ASSEMBLEUR_VERSION "1.5"
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
|
||||||
|
|||||||
34
test.asm
34
test.asm
@@ -1,21 +1,21 @@
|
|||||||
operations:
|
operations:
|
||||||
add R1 R2 #1
|
ADD R1 R2 #1
|
||||||
sub R1 R2 R3
|
SUB R1 R2 R3
|
||||||
and R1 R2 #33
|
AND R1 R2 #33
|
||||||
xor R1 R2 R3
|
XOR R1 R2 R3
|
||||||
or R1 R2 R3
|
OR R1 R2 R3
|
||||||
sl R1 R2 R3
|
SL R1 R2 R3
|
||||||
sr R1 R2 R3
|
SR R1 R2 R3
|
||||||
mul R1 R2 R3
|
MUL R1 R2 R3
|
||||||
io:
|
io:
|
||||||
str R1 R2 R3
|
STR R1 R2 R3
|
||||||
ld R1 R2 R3
|
LD R1 R2 R3
|
||||||
sauts:
|
sauts:
|
||||||
jmp controle
|
JMP controle
|
||||||
jequ R1 R2 io
|
JEQU R1 R2 io
|
||||||
jneq R1 R2 sauts
|
JNEQ R1 R2 sauts
|
||||||
jsup R1 R2 operations
|
JSUP R1 R2 operations
|
||||||
jinf R1 R2 controle
|
JINF R1 R2 controle
|
||||||
controle:
|
controle:
|
||||||
call io
|
CALL io
|
||||||
ret
|
RET
|
||||||
|
|||||||
Reference in New Issue
Block a user