Improved formatting of load and store commands

This commit is contained in:
2025-02-16 19:29:22 +01:00
parent c633f94d29
commit dc3ba6504f
4 changed files with 36 additions and 23 deletions

View File

@ -2,7 +2,6 @@ package asm
import (
"fmt"
"math"
"git.akyoto.dev/cli/q/src/cpu"
)
@ -15,11 +14,7 @@ type MemoryRegister struct {
// String returns a human readable version.
func (data *MemoryRegister) String() string {
if data.Address.OffsetRegister == math.MaxUint8 {
return fmt.Sprintf("%dB [%s+%d], %s", data.Address.Length, data.Address.Base, data.Address.Offset, data.Register)
}
return fmt.Sprintf("%dB [%s+%s+%d], %s", data.Address.Length, data.Address.Base, data.Address.OffsetRegister, data.Address.Offset, data.Register)
return data.Address.Format(fmt.Sprint(data.Register))
}
// MemoryRegister adds an instruction with a memory address and a number.