From c5d4231ead7f3fcd9d61f1a4c920806314f3878b Mon Sep 17 00:00:00 2001 From: Fabrice Desclaux Date: Sat, 27 Apr 2024 14:35:09 +0200 Subject: [PATCH] Fix add/sub aarch64 --- miasm/arch/aarch64/arch.py | 9 +++++++-- test/arch/aarch64/arch.py | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/miasm/arch/aarch64/arch.py b/miasm/arch/aarch64/arch.py index 0ade16bf7..c642d2010 100644 --- a/miasm/arch/aarch64/arch.py +++ b/miasm/arch/aarch64/arch.py @@ -1909,6 +1909,10 @@ def encode(self): bs_adsu_name = bs_name(l=1, name=adsu_name) +adsus_name = {'ADDS': 0, 'SUBS': 1} +bs_adsus_name = bs_name(l=1, name=adsus_name) + + offs19 = bs(l=19, cls=(aarch64_offs,), fname='off') offs19pc = bs(l=19, cls=(aarch64_offs_pc,), fname='off') @@ -1939,8 +1943,9 @@ def encode(self): aarch64op("cmp", [sf, bs('1'), bs('1'), bs('01011'), shift, bs('0'), rm_sft, imm6, rn, bs('11111')], [rn, rm_sft], alias=True) # add/sub (reg ext) -aarch64op("addsub", [sf, bs_adsu_name, modf, bs('01011'), bs('00'), bs('1'), rm_ext, option, imm3, rn, rd], [rd, rn, rm_ext]) -#aarch64op("cmp", [sf, bs('1'), bs('1'), bs('01011'), bs('00'), bs('1'), rm_ext, option, imm3, rn, bs('11111')], [rn, rm_ext], alias=True) +aarch64op("addsub", [sf, bs_adsu_name, bs('0'), bs('01011'), bs('00'), bs('1'), rm_ext, option, imm3, rn, rd], [rd, rn, rm_ext]) +aarch64op("addssubs", [sf, bs_adsus_name, bs('1'), bs('01011'), bs('00'), bs('1'), rm_ext, option, imm3, rn, rd_nosp], [rd_nosp, rn, rm_ext]) +aarch64op("cmp", [sf, bs('1'), bs('1'), bs('01011'), bs('00'), bs('1'), rm_ext, option, imm3, rn, bs('11111')], [rn, rm_ext], alias=True) aarch64op("neg", [sf, bs('1'), modf, bs('01011'), shift, bs('0'), rm_sft, imm6, bs('11111'), rd], [rd, rm_sft], alias=True) diff --git a/test/arch/aarch64/arch.py b/test/arch/aarch64/arch.py index 57ec9b14e..4156e054c 100644 --- a/test/arch/aarch64/arch.py +++ b/test/arch/aarch64/arch.py @@ -67,6 +67,9 @@ ("0000D5AC NEG W6, W6", "E603064B"), + ("XXXXXXXX CMP W11, W12 UXTB 0x0", + "7F012C6B"), + ("004028B8 CMP X0, XZR", "1F001FEB"),