Implement basic add and sub

master
Raymon Zutekouw 2 years ago
parent 0bdd6364a7
commit 123c1cee64
No known key found for this signature in database
GPG Key ID: 1E9BCC39EDD1DD53
  1. 4
      src/main.rs

@ -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);

Loading…
Cancel
Save