Implemented subtraction

This commit is contained in:
2024-06-24 16:55:15 +02:00
parent 597cb9abed
commit b018d8de61
9 changed files with 92 additions and 28 deletions

View File

@ -118,7 +118,13 @@ func (f *Function) CompileInstruction(line token.List) error {
case "+=":
name := expr.Children[0].Token.Text()
number, _ := strconv.Atoi(expr.Children[1].Token.Text())
f.Assembler.AddRegisterNumber(f.Variables[name].Register, uint64(number))
f.Assembler.AddRegisterNumber(f.Variables[name].Register, number)
return nil
case "-=":
name := expr.Children[0].Token.Text()
number, _ := strconv.Atoi(expr.Children[1].Token.Text())
f.Assembler.SubRegisterNumber(f.Variables[name].Register, number)
return nil
}
}
@ -158,7 +164,7 @@ func (f *Function) TokenToRegister(t token.Token, register cpu.Register) error {
return err
}
f.Assembler.MoveRegisterNumber(register, uint64(n))
f.Assembler.MoveRegisterNumber(register, n)
return nil
case token.String: