Renamed x64 store function
This commit is contained in:
parent
6dad6fb6a6
commit
bc8e7e452d
@ -291,13 +291,13 @@ func (a Assembler) Finalize(dlls dll.List) ([]byte, []byte) {
|
|||||||
if operands.Address.OffsetRegister == math.MaxUint8 {
|
if operands.Address.OffsetRegister == math.MaxUint8 {
|
||||||
code = x64.StoreNumber(code, operands.Address.Base, operands.Address.Offset, operands.Address.Length, operands.Number)
|
code = x64.StoreNumber(code, operands.Address.Base, operands.Address.Offset, operands.Address.Length, operands.Number)
|
||||||
} else {
|
} 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:
|
case *MemoryRegister:
|
||||||
if operands.Address.OffsetRegister == math.MaxUint8 {
|
if operands.Address.OffsetRegister == math.MaxUint8 {
|
||||||
code = x64.StoreRegister(code, operands.Address.Base, operands.Address.Offset, operands.Address.Length, operands.Register)
|
code = x64.StoreRegister(code, operands.Address.Base, operands.Address.Offset, operands.Address.Length, operands.Register)
|
||||||
} else {
|
} 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
"git.akyoto.dev/cli/q/src/cpu"
|
"git.akyoto.dev/cli/q/src/cpu"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StoreDynamicOffsetNumber stores a number into the memory address at `destination` with a register offset.
|
// StoreDynamicNumber 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 {
|
func StoreDynamicNumber(code []byte, destination cpu.Register, offset cpu.Register, length byte, number int) []byte {
|
||||||
var (
|
var (
|
||||||
w = byte(0)
|
w = byte(0)
|
||||||
r = byte(0)
|
r = byte(0)
|
||||||
@ -69,8 +69,8 @@ func StoreDynamicOffsetNumber(code []byte, destination cpu.Register, offset cpu.
|
|||||||
return append(code, byte(number))
|
return append(code, byte(number))
|
||||||
}
|
}
|
||||||
|
|
||||||
// StoreDynamicOffsetRegister stores the contents of the `source` register into the memory address at `destination` with a register offset.
|
// StoreDynamicRegister 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 {
|
func StoreDynamicRegister(code []byte, destination cpu.Register, offset cpu.Register, length byte, source cpu.Register) []byte {
|
||||||
var (
|
var (
|
||||||
w = byte(0)
|
w = byte(0)
|
||||||
r = byte(0)
|
r = byte(0)
|
@ -8,7 +8,7 @@ import (
|
|||||||
"git.akyoto.dev/go/assert"
|
"git.akyoto.dev/go/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestStoreDynamicOffsetNumber(t *testing.T) {
|
func TestStoreDynamicNumber(t *testing.T) {
|
||||||
usagePatterns := []struct {
|
usagePatterns := []struct {
|
||||||
RegisterTo cpu.Register
|
RegisterTo cpu.Register
|
||||||
Offset cpu.Register
|
Offset cpu.Register
|
||||||
@ -84,12 +84,12 @@ func TestStoreDynamicOffsetNumber(t *testing.T) {
|
|||||||
|
|
||||||
for _, pattern := range usagePatterns {
|
for _, pattern := range usagePatterns {
|
||||||
t.Logf("store %dB [%s+%s], %d", pattern.Length, pattern.RegisterTo, pattern.Offset, pattern.Number)
|
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)
|
assert.DeepEqual(t, code, pattern.Code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStoreDynamicOffsetRegister(t *testing.T) {
|
func TestStoreDynamicRegister(t *testing.T) {
|
||||||
usagePatterns := []struct {
|
usagePatterns := []struct {
|
||||||
RegisterTo cpu.Register
|
RegisterTo cpu.Register
|
||||||
Offset cpu.Register
|
Offset cpu.Register
|
||||||
@ -165,7 +165,7 @@ func TestStoreDynamicOffsetRegister(t *testing.T) {
|
|||||||
|
|
||||||
for _, pattern := range usagePatterns {
|
for _, pattern := range usagePatterns {
|
||||||
t.Logf("store %dB [%s+%s], %s", pattern.Length, pattern.RegisterTo, pattern.Offset, pattern.RegisterFrom)
|
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)
|
assert.DeepEqual(t, code, pattern.Code)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user