Renamed x64 store function

This commit is contained in:
Eduard Urbach 2025-01-25 23:18:57 +01:00
parent 6dad6fb6a6
commit bc8e7e452d
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
3 changed files with 10 additions and 10 deletions

View File

@ -291,13 +291,13 @@ func (a Assembler) Finalize(dlls dll.List) ([]byte, []byte) {
if operands.Address.OffsetRegister == math.MaxUint8 {
code = x64.StoreNumber(code, operands.Address.Base, operands.Address.Offset, operands.Address.Length, operands.Number)
} else {
code = x64.StoreDynamicOffsetNumber(code, operands.Address.Base, operands.Address.OffsetRegister, operands.Address.Length, operands.Number)
code = x64.StoreDynamicNumber(code, operands.Address.Base, operands.Address.OffsetRegister, operands.Address.Length, operands.Number)
}
case *MemoryRegister:
if operands.Address.OffsetRegister == math.MaxUint8 {
code = x64.StoreRegister(code, operands.Address.Base, operands.Address.Offset, operands.Address.Length, operands.Register)
} else {
code = x64.StoreDynamicOffsetRegister(code, operands.Address.Base, operands.Address.OffsetRegister, operands.Address.Length, operands.Register)
code = x64.StoreDynamicRegister(code, operands.Address.Base, operands.Address.OffsetRegister, operands.Address.Length, operands.Register)
}
}

View File

@ -6,8 +6,8 @@ import (
"git.akyoto.dev/cli/q/src/cpu"
)
// StoreDynamicOffsetNumber stores a number into the memory address at `destination` with a register offset.
func StoreDynamicOffsetNumber(code []byte, destination cpu.Register, offset cpu.Register, length byte, number int) []byte {
// StoreDynamicNumber stores a number into the memory address at `destination` with a register offset.
func StoreDynamicNumber(code []byte, destination cpu.Register, offset cpu.Register, length byte, number int) []byte {
var (
w = byte(0)
r = byte(0)
@ -69,8 +69,8 @@ func StoreDynamicOffsetNumber(code []byte, destination cpu.Register, offset cpu.
return append(code, byte(number))
}
// StoreDynamicOffsetRegister stores the contents of the `source` register into the memory address at `destination` with a register offset.
func StoreDynamicOffsetRegister(code []byte, destination cpu.Register, offset cpu.Register, length byte, source cpu.Register) []byte {
// StoreDynamicRegister stores the contents of the `source` register into the memory address at `destination` with a register offset.
func StoreDynamicRegister(code []byte, destination cpu.Register, offset cpu.Register, length byte, source cpu.Register) []byte {
var (
w = byte(0)
r = byte(0)

View File

@ -8,7 +8,7 @@ import (
"git.akyoto.dev/go/assert"
)
func TestStoreDynamicOffsetNumber(t *testing.T) {
func TestStoreDynamicNumber(t *testing.T) {
usagePatterns := []struct {
RegisterTo cpu.Register
Offset cpu.Register
@ -84,12 +84,12 @@ func TestStoreDynamicOffsetNumber(t *testing.T) {
for _, pattern := range usagePatterns {
t.Logf("store %dB [%s+%s], %d", pattern.Length, pattern.RegisterTo, pattern.Offset, pattern.Number)
code := x64.StoreDynamicOffsetNumber(nil, pattern.RegisterTo, pattern.Offset, pattern.Length, pattern.Number)
code := x64.StoreDynamicNumber(nil, pattern.RegisterTo, pattern.Offset, pattern.Length, pattern.Number)
assert.DeepEqual(t, code, pattern.Code)
}
}
func TestStoreDynamicOffsetRegister(t *testing.T) {
func TestStoreDynamicRegister(t *testing.T) {
usagePatterns := []struct {
RegisterTo cpu.Register
Offset cpu.Register
@ -165,7 +165,7 @@ func TestStoreDynamicOffsetRegister(t *testing.T) {
for _, pattern := range usagePatterns {
t.Logf("store %dB [%s+%s], %s", pattern.Length, pattern.RegisterTo, pattern.Offset, pattern.RegisterFrom)
code := x64.StoreDynamicOffsetRegister(nil, pattern.RegisterTo, pattern.Offset, pattern.Length, pattern.RegisterFrom)
code := x64.StoreDynamicRegister(nil, pattern.RegisterTo, pattern.Offset, pattern.Length, pattern.RegisterFrom)
assert.DeepEqual(t, code, pattern.Code)
}
}