package x64_test import ( "testing" "git.akyoto.dev/cli/q/src/cpu" "git.akyoto.dev/cli/q/src/x64" "git.akyoto.dev/go/assert" ) func TestDivRegister(t *testing.T) { usagePatterns := []struct { Register cpu.Register Code []byte }{ {x64.RAX, []byte{0x48, 0xF7, 0xF8}}, {x64.RCX, []byte{0x48, 0xF7, 0xF9}}, {x64.RDX, []byte{0x48, 0xF7, 0xFA}}, {x64.RBX, []byte{0x48, 0xF7, 0xFB}}, {x64.RSP, []byte{0x48, 0xF7, 0xFC}}, {x64.RBP, []byte{0x48, 0xF7, 0xFD}}, {x64.RSI, []byte{0x48, 0xF7, 0xFE}}, {x64.RDI, []byte{0x48, 0xF7, 0xFF}}, {x64.R8, []byte{0x49, 0xF7, 0xF8}}, {x64.R9, []byte{0x49, 0xF7, 0xF9}}, {x64.R10, []byte{0x49, 0xF7, 0xFA}}, {x64.R11, []byte{0x49, 0xF7, 0xFB}}, {x64.R12, []byte{0x49, 0xF7, 0xFC}}, {x64.R13, []byte{0x49, 0xF7, 0xFD}}, {x64.R14, []byte{0x49, 0xF7, 0xFE}}, {x64.R15, []byte{0x49, 0xF7, 0xFF}}, } for _, pattern := range usagePatterns { t.Logf("idiv %s", pattern.Register) code := x64.DivRegister(nil, pattern.Register) assert.DeepEqual(t, code, pattern.Code) } }