Implemented addition

This commit is contained in:
Eduard Urbach 2024-06-24 14:14:07 +02:00
parent b6722c5482
commit 0657b88945
Signed by: eduard
GPG key ID: 49226B848C78F6C8
6 changed files with 78 additions and 23 deletions

View file

@ -113,6 +113,16 @@ func (f *Function) CompileInstruction(line token.List) error {
return f.CompileFunctionCall(expr)
}
if expr.Token.Kind == token.Operator {
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, uint64(number))
return nil
}
}
return errors.New(&errors.InvalidInstruction{Instruction: expr.Token.Text()}, f.File, expr.Token.Position)
}