Implemented simple expressions

This commit is contained in:
Eduard Urbach 2024-06-25 20:50:06 +02:00
parent c437b1d0f8
commit 37e222e022
Signed by: eduard
GPG key ID: 49226B848C78F6C8
12 changed files with 232 additions and 52 deletions

View file

@ -55,3 +55,34 @@ func TestMulRegisterNumber(t *testing.T) {
assert.DeepEqual(t, code, pattern.Code)
}
}
func TestMulRegisterRegister(t *testing.T) {
usagePatterns := []struct {
Left cpu.Register
Right cpu.Register
Code []byte
}{
{x64.RAX, x64.R15, []byte{0x49, 0x0F, 0xAF, 0xC7}},
{x64.RCX, x64.R14, []byte{0x49, 0x0F, 0xAF, 0xCE}},
{x64.RDX, x64.R13, []byte{0x49, 0x0F, 0xAF, 0xD5}},
{x64.RBX, x64.R12, []byte{0x49, 0x0F, 0xAF, 0xDC}},
{x64.RSP, x64.R11, []byte{0x49, 0x0F, 0xAF, 0xE3}},
{x64.RBP, x64.R10, []byte{0x49, 0x0F, 0xAF, 0xEA}},
{x64.RSI, x64.R9, []byte{0x49, 0x0F, 0xAF, 0xF1}},
{x64.RDI, x64.R8, []byte{0x49, 0x0F, 0xAF, 0xF8}},
{x64.R8, x64.RDI, []byte{0x4C, 0x0F, 0xAF, 0xC7}},
{x64.R9, x64.RSI, []byte{0x4C, 0x0F, 0xAF, 0xCE}},
{x64.R10, x64.RBP, []byte{0x4C, 0x0F, 0xAF, 0xD5}},
{x64.R11, x64.RSP, []byte{0x4C, 0x0F, 0xAF, 0xDC}},
{x64.R12, x64.RBX, []byte{0x4C, 0x0F, 0xAF, 0xE3}},
{x64.R13, x64.RDX, []byte{0x4C, 0x0F, 0xAF, 0xEA}},
{x64.R14, x64.RCX, []byte{0x4C, 0x0F, 0xAF, 0xF1}},
{x64.R15, x64.RAX, []byte{0x4C, 0x0F, 0xAF, 0xF8}},
}
for _, pattern := range usagePatterns {
t.Logf("mul %s, %s", pattern.Left, pattern.Right)
code := x64.MulRegReg(nil, pattern.Left, pattern.Right)
assert.DeepEqual(t, code, pattern.Code)
}
}