Re: disassembler prefix-byte check -- wanting comments good and bad
From: wolfgang kern (nowhere_at_nevernet.at)
Date: 03/29/04
- Next message: wolfgang kern: "Re: newbe about API"
- Previous message: Frank Kotler: "Re: NASM and push byte, ret; ret 4; ret 16"
- In reply to: Bx.C: "Re: disassembler prefix-byte check -- wanting comments good and bad"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 29 Mar 2004 16:39:25 +0200
"Bx.C" wrote:
| > The point here are the 'F3' prefix for SSE2 extensions,
| > even I see it as prefix (128/64 bit or xmm/mmx) also,
| > the meaning is quite different related to the REP/REPNZ usage.
| huh... *looks* ...oh that? ...that's why you don't write the prefix mnemonic
| or opcode mnemonic to your string buffer or display area until you know what
| your opcode is...
| i would rather this:
| cs:0100 26 00 06 59 38 add [es:3859],al
| over this:
| cs:0100 26 es:
| cs:0101 00 06 59 38 add [3859],al
Yes, my disassembler work that (first) way.
All prefix-bytes just set,reset or toggle a dedicated bit in the
dis-"ass"-flags variable.
ie: a JMP FAR to 32-bit code sets pm32-, op_size- and ad_size-flags,
any following occurence of 66 or 67 will toggle (xor) this bits
(doubles are reported as erreanous and will be ignored),
while seg-overrides, LOCK and REP are only set temporary (cleared ahead).
I reserved 32-bits to keep track of the disassembler flow:
26,2e,36,3e,64,65,66,67,f0,f2,f3,pm32,vm86,...
others are used for cc-branch-oriented disASM, loop- and dup(bwq)-detection.
| ...you handle this situation in a similar way...
| mark down your prefix flag somewhere... start figuring out what the first
| thing is that needs to be displayed, and display it... when you get
| to a point where you need to check prefix bytes before displaying
| something, check them..
| so... the same w/ the SSEx instructions
Yes, even with 3Dnow!, which got the opcode in the last byte.
But before any display I concoct mnemonic, source, destination,
verbose comments and other gained info in separated buffers.
This way I save on extra decoding for all destin/source-swapped
instructions ie:
89 06 mov [esi],eax
8b 06 mov eax,[esi]
works both as 88 (AND FC)
and use the origin (bit0) 'word-bit' to say EAX or AL
and finally use the origin (bit1) 'direction-flag'
to tell about display-, or better the string compilation-order.
| i welcome an actual example that looks difficult...
| the worst one that can be found... it'll
| keep me thinking of better and better ways to improve this project...
Hmm, what's difficult in your view?
in terms of disassemble perhaps the error detection in faulty code:
f0 2e 66 0f 7e 64 c4 ff ff MOVD ;"lock?"/"CS-WR"/"misaligned"
or
f3 36 0f 0f 46 82 97 PFSQRT mm2,SS:[ESI-7e] ;"can't REP"/"misaligned?"
while
36 f3 0f 7e 05 21 43 65 87 MOVQ xmm1,SS:[87654321h] ;Zx m64
may be Ok, even this stack-access is misaligned and will exceed limits.
__
wolfgang
- Next message: wolfgang kern: "Re: newbe about API"
- Previous message: Frank Kotler: "Re: NASM and push byte, ret; ret 4; ret 16"
- In reply to: Bx.C: "Re: disassembler prefix-byte check -- wanting comments good and bad"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|