Skip to content

Commit

Permalink
Applied some of the syntax recomandations from https://cdrdv2.intel.c…
Browse files Browse the repository at this point in the history
  • Loading branch information
vlutas committed Mar 4, 2024
1 parent 02cbe6a commit 37a8c94
Show file tree
Hide file tree
Showing 8 changed files with 2,810 additions and 2,604 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@ All notable (user-facing) changes to this project will be documented in this fil
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).


## [2.1.3] - 2024-03-04

### Changed
- Aligned BDDISASM APX instructions syntax with some of the Intel recomandations (using the suffix notation for `NF` and `ZU` indications, using finite set notation for `DFV` operands).

### Disassembly differences
- The `ZU` indication is appended as a mnemonic sufix, as per recomandations. However, in case of `SETcc` instructions, BDDISASM will append the `ZU` indication AFTER the condition code (similar to `CMPccXADD` and with initial `SETcc.ZU` specification).
- The `DFV` (default flags value) operand obeys the finite set notation, but it is placed as the last operand of the instruction.


## [2.1.2] - 2024-02-27

### Added
- `Read` access for the `rIP` operand for the `SYSCALL` instruction.
- `SCS`, `rCX`, `rDX` operands for the `SYSEXIT` instruction.


## [2.1.1] - 2024-02-26

### Added
- `Read` access for the `rIP` operand for some `CALL` instructions.


## [2.1.0] - 2024-02-20

Expand Down
42 changes: 32 additions & 10 deletions bddisasm/bdx86_formatter.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,14 @@ NdToText(
// Store NF specifier, if NoFlags presetn.
if (Instrux->HasNf)
{
res = nd_strcat_s(Buffer, BufferSize, "{NF}");
res = nd_strcat_s(Buffer, BufferSize, "NF");
RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
}

// Store ZU specifier, if ZeroUpper present.
if (Instrux->HasZu)
{
res = nd_strcat_s(Buffer, BufferSize, "{ZU}");
res = nd_strcat_s(Buffer, BufferSize, "ZU");
RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
}

Expand Down Expand Up @@ -710,17 +710,39 @@ NdToText(

case ND_OP_DFV:
{
status = NdSprintf(temp, sizeof(temp), "%c%c%c%c",
pOp->Info.DefaultFlags.OF ? '1' : '0',
pOp->Info.DefaultFlags.SF ? '1' : '0',
pOp->Info.DefaultFlags.ZF ? '1' : '0',
pOp->Info.DefaultFlags.CF ? '1' : '0');
if (!ND_SUCCESS(status))
ND_BOOL comma = ND_FALSE;

res = nd_strcat_s(Buffer, BufferSize, "{dfv=");
RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);

if (pOp->Info.DefaultFlags.OF)
{
return status;
res = nd_strcat_s(Buffer, BufferSize, "OF");
RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
comma = ND_TRUE;
}

res = nd_strcat_s(Buffer, BufferSize, temp);
if (pOp->Info.DefaultFlags.SF)
{
res = nd_strcat_s(Buffer, BufferSize, comma ? ",SF" : "SF");
RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
comma = ND_TRUE;
}

if (pOp->Info.DefaultFlags.ZF)
{
res = nd_strcat_s(Buffer, BufferSize, comma ? ",ZF" : "ZF");
RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
comma = ND_TRUE;
}

if (pOp->Info.DefaultFlags.CF)
{
res = nd_strcat_s(Buffer, BufferSize, comma ? ",CF" : "CF");
RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
}

res = nd_strcat_s(Buffer, BufferSize, "}");
RET_EQ(res, ND_NULL, ND_STATUS_BUFFER_OVERFLOW);
}
break;
Expand Down
5,184 changes: 2,592 additions & 2,592 deletions bddisasm_test/x86/apx/apx1_64.result

Large diffs are not rendered by default.

161 changes: 161 additions & 0 deletions bddisasm_test/x86/apx/apx3_64.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
0000000000000000 626c8902813ebdbdbdbd CCMPC qword ptr [r22], 0xbdbdbdbd, {dfv=OF,SF,ZF}
DSIZE: 64, ASIZE: 64, VLEN: -
ISA Set: APX_F, Ins cat: APX, CET tracked: no
CPUID leaf: 0x00000007, sub-leaf: 0x00000001, reg: edx, bit: 21
EVEX Tuple Type: None
Exception class: APX, exception type: APX-EVEX-CCMP
FLAGS access
CF: t,
Valid modes
R0: yes, R1: yes, R2: yes, R3: yes
Real: no, V8086: no, Prot: yes, Compat: yes, Long: yes
SMM on: yes, SMM off: yes, SGX on: yes, SGX off: yes, TSX on: yes, TSX off: yes
VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes
Valid prefixes
REP: no, REPcc: no, LOCK: no
HLE: no, XACQUIRE only: no, XRELEASE only: no
BND: no, BHINT: no, DNT: no
Operand: 0, Acc: R-, Type: Memory, Size: 8, RawSize: 8, Encoding: M,
Segment: 3, Base: 22,
Operand: 1, Acc: R-, Type: Immediate, Size: 4, RawSize: 4, Encoding: I
Operand: 2, Acc: R-, Type: Default flags, Size: 0, RawSize: 0, Encoding: V
Operand: 3, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Flags, RegSize: 8, RegId: 0, RegCount: 1

000000000000000A 626c9902813ebdbdbdbd CCMPC qword ptr [r22], 0xbdbdbdbd, {dfv=OF,SF}
DSIZE: 64, ASIZE: 64, VLEN: -
ISA Set: APX_F, Ins cat: APX, CET tracked: no
CPUID leaf: 0x00000007, sub-leaf: 0x00000001, reg: edx, bit: 21
EVEX Tuple Type: None
Exception class: APX, exception type: APX-EVEX-CCMP
FLAGS access
CF: t,
Valid modes
R0: yes, R1: yes, R2: yes, R3: yes
Real: no, V8086: no, Prot: yes, Compat: yes, Long: yes
SMM on: yes, SMM off: yes, SGX on: yes, SGX off: yes, TSX on: yes, TSX off: yes
VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes
Valid prefixes
REP: no, REPcc: no, LOCK: no
HLE: no, XACQUIRE only: no, XRELEASE only: no
BND: no, BHINT: no, DNT: no
Operand: 0, Acc: R-, Type: Memory, Size: 8, RawSize: 8, Encoding: M,
Segment: 3, Base: 22,
Operand: 1, Acc: R-, Type: Immediate, Size: 4, RawSize: 4, Encoding: I
Operand: 2, Acc: R-, Type: Default flags, Size: 0, RawSize: 0, Encoding: V
Operand: 3, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Flags, RegSize: 8, RegId: 0, RegCount: 1

0000000000000014 626cc902813ebdbdbdbd CCMPC qword ptr [r22], 0xbdbdbdbd, {dfv=SF,ZF}
DSIZE: 64, ASIZE: 64, VLEN: -
ISA Set: APX_F, Ins cat: APX, CET tracked: no
CPUID leaf: 0x00000007, sub-leaf: 0x00000001, reg: edx, bit: 21
EVEX Tuple Type: None
Exception class: APX, exception type: APX-EVEX-CCMP
FLAGS access
CF: t,
Valid modes
R0: yes, R1: yes, R2: yes, R3: yes
Real: no, V8086: no, Prot: yes, Compat: yes, Long: yes
SMM on: yes, SMM off: yes, SGX on: yes, SGX off: yes, TSX on: yes, TSX off: yes
VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes
Valid prefixes
REP: no, REPcc: no, LOCK: no
HLE: no, XACQUIRE only: no, XRELEASE only: no
BND: no, BHINT: no, DNT: no
Operand: 0, Acc: R-, Type: Memory, Size: 8, RawSize: 8, Encoding: M,
Segment: 3, Base: 22,
Operand: 1, Acc: R-, Type: Immediate, Size: 4, RawSize: 4, Encoding: I
Operand: 2, Acc: R-, Type: Default flags, Size: 0, RawSize: 0, Encoding: V
Operand: 3, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Flags, RegSize: 8, RegId: 0, RegCount: 1

000000000000001E 626cd902813ebdbdbdbd CCMPC qword ptr [r22], 0xbdbdbdbd, {dfv=SF}
DSIZE: 64, ASIZE: 64, VLEN: -
ISA Set: APX_F, Ins cat: APX, CET tracked: no
CPUID leaf: 0x00000007, sub-leaf: 0x00000001, reg: edx, bit: 21
EVEX Tuple Type: None
Exception class: APX, exception type: APX-EVEX-CCMP
FLAGS access
CF: t,
Valid modes
R0: yes, R1: yes, R2: yes, R3: yes
Real: no, V8086: no, Prot: yes, Compat: yes, Long: yes
SMM on: yes, SMM off: yes, SGX on: yes, SGX off: yes, TSX on: yes, TSX off: yes
VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes
Valid prefixes
REP: no, REPcc: no, LOCK: no
HLE: no, XACQUIRE only: no, XRELEASE only: no
BND: no, BHINT: no, DNT: no
Operand: 0, Acc: R-, Type: Memory, Size: 8, RawSize: 8, Encoding: M,
Segment: 3, Base: 22,
Operand: 1, Acc: R-, Type: Immediate, Size: 4, RawSize: 4, Encoding: I
Operand: 2, Acc: R-, Type: Default flags, Size: 0, RawSize: 0, Encoding: V
Operand: 3, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Flags, RegSize: 8, RegId: 0, RegCount: 1

0000000000000028 626ce902813ebdbdbdbd CCMPC qword ptr [r22], 0xbdbdbdbd, {dfv=ZF}
DSIZE: 64, ASIZE: 64, VLEN: -
ISA Set: APX_F, Ins cat: APX, CET tracked: no
CPUID leaf: 0x00000007, sub-leaf: 0x00000001, reg: edx, bit: 21
EVEX Tuple Type: None
Exception class: APX, exception type: APX-EVEX-CCMP
FLAGS access
CF: t,
Valid modes
R0: yes, R1: yes, R2: yes, R3: yes
Real: no, V8086: no, Prot: yes, Compat: yes, Long: yes
SMM on: yes, SMM off: yes, SGX on: yes, SGX off: yes, TSX on: yes, TSX off: yes
VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes
Valid prefixes
REP: no, REPcc: no, LOCK: no
HLE: no, XACQUIRE only: no, XRELEASE only: no
BND: no, BHINT: no, DNT: no
Operand: 0, Acc: R-, Type: Memory, Size: 8, RawSize: 8, Encoding: M,
Segment: 3, Base: 22,
Operand: 1, Acc: R-, Type: Immediate, Size: 4, RawSize: 4, Encoding: I
Operand: 2, Acc: R-, Type: Default flags, Size: 0, RawSize: 0, Encoding: V
Operand: 3, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Flags, RegSize: 8, RegId: 0, RegCount: 1

0000000000000032 626cf102813ebdbdbdbd CCMPC qword ptr [r22], 0xbdbdbdbd, {dfv=CF}
DSIZE: 64, ASIZE: 64, VLEN: -
ISA Set: APX_F, Ins cat: APX, CET tracked: no
CPUID leaf: 0x00000007, sub-leaf: 0x00000001, reg: edx, bit: 21
EVEX Tuple Type: None
Exception class: APX, exception type: APX-EVEX-CCMP
FLAGS access
CF: t,
Valid modes
R0: yes, R1: yes, R2: yes, R3: yes
Real: no, V8086: no, Prot: yes, Compat: yes, Long: yes
SMM on: yes, SMM off: yes, SGX on: yes, SGX off: yes, TSX on: yes, TSX off: yes
VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes
Valid prefixes
REP: no, REPcc: no, LOCK: no
HLE: no, XACQUIRE only: no, XRELEASE only: no
BND: no, BHINT: no, DNT: no
Operand: 0, Acc: R-, Type: Memory, Size: 8, RawSize: 8, Encoding: M,
Segment: 3, Base: 22,
Operand: 1, Acc: R-, Type: Immediate, Size: 4, RawSize: 4, Encoding: I
Operand: 2, Acc: R-, Type: Default flags, Size: 0, RawSize: 0, Encoding: V
Operand: 3, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Flags, RegSize: 8, RegId: 0, RegCount: 1

000000000000003C 626c8102813ebdbdbdbd CCMPC qword ptr [r22], 0xbdbdbdbd, {dfv=OF,SF,ZF,CF}
DSIZE: 64, ASIZE: 64, VLEN: -
ISA Set: APX_F, Ins cat: APX, CET tracked: no
CPUID leaf: 0x00000007, sub-leaf: 0x00000001, reg: edx, bit: 21
EVEX Tuple Type: None
Exception class: APX, exception type: APX-EVEX-CCMP
FLAGS access
CF: t,
Valid modes
R0: yes, R1: yes, R2: yes, R3: yes
Real: no, V8086: no, Prot: yes, Compat: yes, Long: yes
SMM on: yes, SMM off: yes, SGX on: yes, SGX off: yes, TSX on: yes, TSX off: yes
VMXRoot: yes, VMXNonRoot: yes, VMXRoot SEAM: yes, VMXNonRoot SEAM: yes, VMX off: yes
Valid prefixes
REP: no, REPcc: no, LOCK: no
HLE: no, XACQUIRE only: no, XRELEASE only: no
BND: no, BHINT: no, DNT: no
Operand: 0, Acc: R-, Type: Memory, Size: 8, RawSize: 8, Encoding: M,
Segment: 3, Base: 22,
Operand: 1, Acc: R-, Type: Immediate, Size: 4, RawSize: 4, Encoding: I
Operand: 2, Acc: R-, Type: Default flags, Size: 0, RawSize: 0, Encoding: V
Operand: 3, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Flags, RegSize: 8, RegId: 0, RegCount: 1

1 change: 1 addition & 0 deletions bddisasm_test/x86/apx/apx3_64.test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bl��>����bl��>����bl��>����bl��>����bl��>����bl��>����bl��>����
Binary file modified bdshemu_test/x86/bdshemu_test_x86.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion bindings/pybddisasm/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from codecs import open

VERSION = (0, 3, 0)
LIBRARY_VERSION = (2, 1, 2)
LIBRARY_VERSION = (2, 1, 3)
DIR_INCLUDE = '../../inc'

here = os.path.abspath(os.path.dirname(__file__))
Expand Down
2 changes: 1 addition & 1 deletion inc/bddisasm_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#define DISASM_VERSION_MAJOR 2
#define DISASM_VERSION_MINOR 1
#define DISASM_VERSION_REVISION 2
#define DISASM_VERSION_REVISION 3

#define SHEMU_VERSION_MAJOR DISASM_VERSION_MAJOR
#define SHEMU_VERSION_MINOR DISASM_VERSION_MINOR
Expand Down

0 comments on commit 37a8c94

Please sign in to comment.