> > This is probably the best idea.  You could have letters like 'S', 'D', ...
> > where a 'S' is replaced by the size of the source operand (op[1].size),
> > while 'D' is replaced by the size of the destination (op[0].size) etc.
> >
> > (Note that you don't need to have separate addb and addw/l, as the
> > source operand size will be 1, 2, or 4 respectively, so just addS
> > should work.)
> 
> That's going to be a LOT of work...
> Can't I just copy the objdump code ?
> Of course, THAT code doesn't support Intel :-/

Why is this a lot of work?  You just need to go through the InsNamesATT
array, and append an 'S' or 'D' to every instruction that needs one,
and then implement a simple loop that replaced those special marker
characters, about like this:

  for ( i = 0; string[i]; i++ )
     switch ( string[i] )
     {
     case 'D':   switch ( dc->op[0].size )
                 {
                 case 1: string[i] = 'b'; break;
                 case 2: string[i] = 'w'; break;
                 case 4: string[i] = 'l'; break;
                 }
                 break;
     case 'S':   switch ( dc->op[1].size )
                 {
                 case 1: string[i] = 'b'; break;
                 case 2: string[i] = 'w'; break;
                 case 4: string[i] = 'l'; break;
                 }
                 break;
     case 'O':   switch ( dc->operand_size )
                 {
                 case 2: string[i] = 'w'; break;
                 case 4: string[i] = 'l'; break;
                 }
                 break;
     }

As to which instructions need which suffixes, I'd say:

 - bswap, cmpxchg8b, pusha/d, popa/d, cwd, cdq, cbw, cbde,
   daa, das, aaa, aas, aam, aad, jmp, j?, jcxz, jecxz,
   loop?, call, ret/f, iret, int, into, enter, leave,
   stc, clc, cmc, std, cld, lahf, sahf, pushf/d, popf/d
   sti, cli, nop, ud2, cpuid, sgdt, lgdt, sidt, lidt,
   smsw, lmsw, clts, arpl, verr, verw, invd, wbinvd, invlpg,
   rep?, lock, hlt, rsm, rdmsr, wrmsr, rdtsc, rdpmc, sysenter,
   sysexit
   No suffix.

 - mov, cmov?, xchg, xadd, cmpxchg, add, adc, sub, sbb,
   imul, mul, idiv, div, inc, dec, neg, cmp, and, or, not, xor, test,
   movs, cmps, lods, stos, lds, les, lfs, lgs, lss, lea
   Either 'S' or 'D'.

 - in, ins, push, pop, inc, dec, 
   sar, shr, sal, shl, shld, shrd, ror, rol, rcr, rcl,
   bt, bts, btr, set?, bound, scas, lar, lsl
   Must use 'D'. 

 - out, outs
   Must use 'S'. 

 - movsx, movzx
   Must use 'SD'. 

 - xlat
   Should use 'O'. (I guess this is not all that important.)

You could cross-check that list against the objdump source to make sure
that the output is the same ...

Bye,
Ulrich

-- 
  Ulrich Weigand,
  IMMD 1, Universitaet Erlangen-Nuernberg,
  Martensstr. 3, D-91058 Erlangen, Phone: +49 9131 85-27688

Reply via email to