Implement basic add and sub
This commit is contained in:
+2
-2
@@ -125,7 +125,7 @@ fn instruct(statement: Pair<Rule>, state: &mut State, out: &mut Builder) {
|
|||||||
"Addition of '{}', decimal value is {}",
|
"Addition of '{}', decimal value is {}",
|
||||||
constant, constant_parsed
|
constant, constant_parsed
|
||||||
);
|
);
|
||||||
out.append("add\n");
|
out.append("+".repeat(constant_parsed as usize));
|
||||||
}
|
}
|
||||||
Rule::addb => {
|
Rule::addb => {
|
||||||
let constant = extract_operand(statement);
|
let constant = extract_operand(statement);
|
||||||
@@ -148,7 +148,7 @@ fn instruct(statement: Pair<Rule>, state: &mut State, out: &mut Builder) {
|
|||||||
"Subtraction of '{}', decimal value is {}",
|
"Subtraction of '{}', decimal value is {}",
|
||||||
constant, constant_parsed
|
constant, constant_parsed
|
||||||
);
|
);
|
||||||
out.append("sub\n");
|
out.append("-".repeat(constant_parsed as usize));
|
||||||
}
|
}
|
||||||
Rule::subb => {
|
Rule::subb => {
|
||||||
let constant = extract_operand(statement);
|
let constant = extract_operand(statement);
|
||||||
|
|||||||
Reference in New Issue
Block a user