Simplified code

This commit is contained in:
2024-07-23 22:14:23 +02:00
parent 69245caf62
commit 26214366e3
30 changed files with 105 additions and 69 deletions

View File

@ -0,0 +1,24 @@
package register
import (
"git.akyoto.dev/cli/q/src/build/asm"
"git.akyoto.dev/cli/q/src/build/cpu"
)
func (f *Machine) RegisterRegister(mnemonic asm.Mnemonic, a cpu.Register, b cpu.Register) {
if mnemonic == asm.MOVE && a == b {
return
}
if f.RegisterIsUsed(a) && isDestructive(mnemonic) {
f.SaveRegister(a)
}
f.Assembler.RegisterRegister(mnemonic, a, b)
if mnemonic == asm.MOVE {
f.UseRegister(a)
}
f.postInstruction()
}