feat(arch): add the scaled index to the amd64 memory operands
Assisted-by: GLM 5.3 Flash
This commit is contained in:
1 parent
ccb155437e
commit
11cac26508
4 files changed
+183
-44
No files matched your search
@@ -141,6 +141,43 @@ func TestAmd64ExtBroadcastEncoding(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAmd64ExtScaledMemoryEncoding pins the SIB layer over the memory
|
||||
// encoding: the scale field, the index and the base in one byte, the r/m
|
||||
// field 100, EVEX.X clearing on an index above 7, and the ModR/M and
|
||||
// displacement choices keeping the plain semantics, RBP's forced
|
||||
// displacement included.
|
||||
func TestAmd64ExtScaledMemoryEncoding(t *testing.T) {
|
||||
add := []byte{0x62, 0x05, 0x04, 0x40, 0x58, 0xC0}
|
||||
for _, tt := range []struct {
|
||||
name string
|
||||
base int
|
||||
index int
|
||||
scale int
|
||||
disp int64
|
||||
want string
|
||||
}{
|
||||
{"scale 1 encodes the scale field zero", 1, 2, 1, 0,
|
||||
"62651440583411"},
|
||||
{"scale 2", 1, 2, 2, 0,
|
||||
"62651440583451"},
|
||||
{"scale 4", 1, 2, 4, 0,
|
||||
"62651440583491"},
|
||||
{"scale 8", 1, 2, 8, 0,
|
||||
"626514405834d1"},
|
||||
{"an index above 7 clears EVEX.X", 1, 12, 2, 0,
|
||||
"62251440583461"},
|
||||
{"RBP base keeps the forced displacement", 5, 14, 8, 0,
|
||||
"622514405874f500"},
|
||||
{"RSP base takes the SIB byte with the index", 12, 3, 4, 0,
|
||||
"6245144058349c"},
|
||||
} {
|
||||
got := amd64EncodeScaledMemory(add, 30, 29, tt.base, tt.index, tt.scale, tt.disp)
|
||||
if hex.EncodeToString(got) != tt.want {
|
||||
t.Errorf("%s:\n got %x\n want %s", tt.name, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestAmd64ExtMemoryVocabulary pins the names the shared layer gives the
|
||||
// memory operand and its two forms.
|
||||
func TestAmd64ExtMemoryVocabulary(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user