Re: disassembler prefix-byte check -- wanting comments good and bad

From: wolfgang kern (nowhere_at_nevernet.at)
Date: 03/29/04


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



Relevant Pages

  • Re: A valid number of prefixes
    ... Finally 0F is listed as part of the OPcode now. ... 0F as a prefix, but then later define it as escaping another 1 or 2 opcode ... then the matcher checks for flags, ... disassembler, and I suspect my disassembler has more than a few subtle ...
    (comp.lang.asm.x86)
  • Re: Prefixes of regular expressions
    ... prefix. ... Match the supplied string against the first; ... If matched, display ... For some situations you could probably use groupCounton the Matcher ...
    (comp.lang.java.programmer)
  • Re: Prefix to Autonumber
    ... If all records have the same prefix, you can display this on a form or report by setting the Format property of your text box to: ...
    (comp.databases.ms-access)
  • Re: OutputTo verus TransferSpreadsheet
    ... Why does it matter? ... The ' is just Excel's default prefix to say "This is ... They don't display or print. ... > How can I avoid that? ...
    (microsoft.public.access.formscoding)
  • Re: Looking for info on IPDB
    ... All the thumbnails for Target Alpha display for me. ... I don't have an explanation for your ... problem assuming you have enough system memory and a sufficiently fast ... do not have a "mirror1" prefix. ...
    (rec.games.pinball)