Improved x64 encoder

This commit is contained in:
2024-06-24 21:54:03 +02:00
parent 862598cfc1
commit 625e8d5e2e
5 changed files with 46 additions and 23 deletions

View File

@ -114,17 +114,17 @@ func (f *Function) CompileInstruction(line token.List) error {
}
if expr.Token.Kind == token.Operator {
name := expr.Children[0].Token.Text()
number, _ := strconv.Atoi(expr.Children[1].Token.Text())
register := f.Variables[name].Register
switch expr.Token.Text() {
case "+=":
name := expr.Children[0].Token.Text()
number, _ := strconv.Atoi(expr.Children[1].Token.Text())
f.Assembler.AddRegisterNumber(f.Variables[name].Register, number)
f.Assembler.AddRegisterNumber(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)
f.Assembler.SubRegisterNumber(register, number)
return nil
}
}