Implemented return values

This commit is contained in:
Eduard Urbach 2024-06-29 21:06:59 +02:00
parent 67b3a3d820
commit a0edc45e19
Signed by: eduard
GPG key ID: 49226B848C78F6C8
7 changed files with 113 additions and 61 deletions

View file

@ -66,6 +66,10 @@ func (a *Assembler) Jump(name string) {
// Return returns back to the caller.
func (a *Assembler) Return() {
if len(a.Instructions) > 0 && a.Instructions[len(a.Instructions)-1].Mnemonic == RETURN {
return
}
a.Instructions = append(a.Instructions, Instruction{Mnemonic: RETURN})
}