Skip to content

Commit

Permalink
Update assembler.
Browse files Browse the repository at this point in the history
  • Loading branch information
thealmarty committed Jan 24, 2024
1 parent a09a5c4 commit 5af1f7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion assembler/grammar/assembly.pest
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mnemonic = {
"advread" | "advwrite" |
"addi" | "add" | "subi" | "sub" | "muli" | "mul" | "mulhsi"| "mulhui"| "mulhs"| "mulhu" | "divi" | "div" | "sdiv" | "sdivi" |
"lti" | "lt" | "shli" | "shl" | "shri" | "shr" | "srai" | "sra" |
"andi" | "and" | "ori" | "or" | "xori" | "xor" |
"andi" | "and" | "ori" | "or" | "xori" | "xor" | "nei" | "ne" | "eqi" | "eq" |
"feadd" | "fesub" | "femul" |
"write"
}
Expand Down
8 changes: 6 additions & 2 deletions assembler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ pub fn assemble(input: &str) -> Result<Vec<u8>, String> {
"and" | "andi" => AND32,
"or" | "ori" => OR32,
"xor" | "xori" => XOR32,
"ne" | "nei" => NE32,
"eq" | "eqi" => EQ32,

// Native field
"feadd" => ADD,
Expand Down Expand Up @@ -116,12 +118,14 @@ pub fn assemble(input: &str) -> Result<Vec<u8>, String> {
operands.extend(vec![0; 5]);
}
"add" | "sub" | "mul" | "mulhs" | "mulhu" | "div" | "lt" | "shl" | "shr"
| "sra" | "beq" | "bne" | "and" | "or" | "xor" | "jal" | "jalv" => {
| "sra" | "beq" | "bne" | "and" | "or" | "xor" | "ne" | "eq" | "jal"
| "jalv" => {
// (a, b, c, 0, 0)
operands.extend(vec![0; 2]);
}
"addi" | "subi" | "muli" | "mulhsi" | "mulhui" | "divi" | "sdivi" | "lti"
| "shli" | "shri" | "srai" | "beqi" | "bnei" | "andi" | "ori" | "xori" => {
| "shli" | "shri" | "srai" | "beqi" | "bnei" | "andi" | "ori" | "xori"
| "nei" | "eqi" => {
// (a, b, c, 0, 1)
operands.extend(vec![0, 1]);
}
Expand Down

0 comments on commit 5af1f7c

Please sign in to comment.