Skip to content
This repository has been archived by the owner on Jan 21, 2023. It is now read-only.

Commit

Permalink
fix ARMv8.4 instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Nov 16, 2020
1 parent 9a554a2 commit 7ac676d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
16 changes: 11 additions & 5 deletions arm64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7480,16 +7480,22 @@ func Test_decompose_v8_4a(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// fmt.Printf("want: %s\n", tt.want)
got, err := decompose(tt.args.instructionValue, tt.args.address)
if (err != nil) != tt.wantErr {
fmt.Printf("want: %s\n", tt.want)
got, _ = decompose(tt.args.instructionValue, tt.args.address)
t.Errorf("disassemble() error = %v, wantErr %v", err, tt.wantErr)
return
}
out, _ := got.disassemble(true)
// fmt.Printf("want: %s\ngot: %s\n", tt.want, out)
if !reflect.DeepEqual(out, tt.want) {
t.Errorf("disassemble(dec) = %v, want %v", out, tt.want)
decOut, _ := got.disassemble(true)
hexout, _ := got.disassemble(false)
if !reflect.DeepEqual(decOut, strings.ToLower(tt.want)) && !reflect.DeepEqual(hexout, strings.ToLower(tt.want)) {
fmt.Printf("want: %s\n", tt.want)
fmt.Printf("got: %s\n", decOut)
fmt.Printf("got: %s (hex)\n", hexout)
got, _ = decompose(tt.args.instructionValue, tt.args.address)
decOut, _ := got.disassemble(true)
t.Errorf("disassemble(dec) = %v, want %v", decOut, tt.want)
}
})
}
Expand Down
7 changes: 4 additions & 3 deletions decompose.go
Original file line number Diff line number Diff line change
Expand Up @@ -1803,9 +1803,10 @@ func (i *Instruction) decompose_load_store_unscaled() (*Instruction, error) {
i.operands[0].Reg[0] = reg(REGSET_ZR, int(regBase[decode.Opc()][decode.Size()]), int(decode.Rt()))
i.operands[1].OpClass = MEM_OFFSET
i.operands[1].Reg[0] = reg(REGSET_SP, REG_X_BASE, int(decode.Rn()))
i.operands[1].SignedImm = 1
i.operands[1].Immediate = uint64(decode.Imm9())
i.operands[1].SignedImm = 1
if decode.Imm9() < 0 {
i.operands[1].SignedImm = 1
}

if i.operation == ARM64_UNDEFINED {
return nil, failedToDisassembleOperation
Expand Down Expand Up @@ -7556,7 +7557,7 @@ func decompose(instructionValue uint32, address uint64) (*Instruction, error) {
}

if ExtractBits(instructionValue, 24, 6) == 25 {
if op0 == 13 {
if op0 == 13 && ExtractBits(instructionValue, 21, 1) != 0 {
return instruction.decompose_load_store_mem_tags()
}
return instruction.decompose_load_store_unscaled()
Expand Down

0 comments on commit 7ac676d

Please sign in to comment.