public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Custom Instructions
@ 2010-09-17 17:50 Nick
  2010-09-17 19:57 ` Ian Lance Taylor
  2010-09-27 11:05 ` Nick Clifton
  0 siblings, 2 replies; 4+ messages in thread
From: Nick @ 2010-09-17 17:50 UTC (permalink / raw)
  To: binutils

Hello everybody,

since this is a group all about binutils, i hope i'm at the right place for my
question. if not, i'd like to apologise in advance; that is also the case if my
questions sound too silly (but i'm a real rookie...).

i'm trying to expand the instruction set recognised by the assembler (part of my
bachelor thesis)(for now only interested in intel architectures). i'm focusing
on binutils-2.20.51/opcodes/i386-opc.tbl, as my assumption is that a
modification of that file should bring the expected results (after re-compiling
gas).

the problem starts at the basics: no matter how much i've looked in the
interwebs, i still don't understand i386-opc.tbl. for example, i don't know what
the parts of this line mean: "mov, 2, 0xc6, 0x0, 1, 0, W|Modrm|No_sSuf|No_ldSuf,

{ Imm8|Imm16|Imm32|Imm32S,
Reg8|Reg16|Reg32|Reg64|Byte|Word|Dword|Qword|Unspecified|BaseIndex|Disp8|Disp16|

Disp32|Disp32S
}". ok, "mov" is the mnemonic, "2" is (guess) the number of operands, in
brackets the type of operands accepted (not all of them clear), but what about
the two hexadecimal values, the "1" and "0"(if not "0" then something like
"Cpu386", "Cpu64"), "No_*Suf"?

one further question would be, do i have to change other files as well (e.g.
i386-opc.h, i386-init.h etc)?

i would really appreciate an answer. sorry again for the, for you probably
trivial, questions.

greetings,
nick

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Custom Instructions
  2010-09-17 17:50 Custom Instructions Nick
@ 2010-09-17 19:57 ` Ian Lance Taylor
  2010-09-17 21:08   ` Nikolaos Ikonomakis
  2010-09-27 11:05 ` Nick Clifton
  1 sibling, 1 reply; 4+ messages in thread
From: Ian Lance Taylor @ 2010-09-17 19:57 UTC (permalink / raw)
  To: Nick; +Cc: binutils

Nick <nikos_ikono1989@yahoo.gr> writes:

> the problem starts at the basics: no matter how much i've looked in the
> interwebs, i still don't understand i386-opc.tbl. for example, i don't know what
> the parts of this line mean: "mov, 2, 0xc6, 0x0, 1, 0, W|Modrm|No_sSuf|No_ldSuf,
>
> { Imm8|Imm16|Imm32|Imm32S,
> Reg8|Reg16|Reg32|Reg64|Byte|Word|Dword|Qword|Unspecified|BaseIndex|Disp8|Disp16|
>
> Disp32|Disp32S
> }". ok, "mov" is the mnemonic, "2" is (guess) the number of operands, in
> brackets the type of operands accepted (not all of them clear), but what about
> the two hexadecimal values, the "1" and "0"(if not "0" then something like
> "Cpu386", "Cpu64"), "No_*Suf"?

See struct insn_template in opcodes/i386-opc.h.

> one further question would be, do i have to change other files as well (e.g.
> i386-opc.h, i386-init.h etc)?

It sort of depends on what you want to do, but probably not.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Custom Instructions
  2010-09-17 19:57 ` Ian Lance Taylor
@ 2010-09-17 21:08   ` Nikolaos Ikonomakis
  0 siblings, 0 replies; 4+ messages in thread
From: Nikolaos Ikonomakis @ 2010-09-17 21:08 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: binutils

Am 17.09.2010 21:57, schrieb Ian Lance Taylor:
> Nick<nikos_ikono1989@yahoo.gr>  writes:
>
>    
>> the problem starts at the basics: no matter how much i've looked in the
>> interwebs, i still don't understand i386-opc.tbl. for example, i don't know what
>> the parts of this line mean: "mov, 2, 0xc6, 0x0, 1, 0, W|Modrm|No_sSuf|No_ldSuf,
>>
>> { Imm8|Imm16|Imm32|Imm32S,
>> Reg8|Reg16|Reg32|Reg64|Byte|Word|Dword|Qword|Unspecified|BaseIndex|Disp8|Disp16|
>>
>> Disp32|Disp32S
>> }". ok, "mov" is the mnemonic, "2" is (guess) the number of operands, in
>> brackets the type of operands accepted (not all of them clear), but what about
>> the two hexadecimal values, the "1" and "0"(if not "0" then something like
>> "Cpu386", "Cpu64"), "No_*Suf"?
>>      
> See struct insn_template in opcodes/i386-opc.h.
>
>    
>> one further question would be, do i have to change other files as well (e.g.
>> i386-opc.h, i386-init.h etc)?
>>      
> It sort of depends on what you want to do, but probably not.
>
> Ian
>
>    
Thank you Ian for your quick reply. I had a glimpse on insn_template and 
it looks just great, many thanx for the hint!

Nick

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Custom Instructions
  2010-09-17 17:50 Custom Instructions Nick
  2010-09-17 19:57 ` Ian Lance Taylor
@ 2010-09-27 11:05 ` Nick Clifton
  1 sibling, 0 replies; 4+ messages in thread
From: Nick Clifton @ 2010-09-27 11:05 UTC (permalink / raw)
  To: Nick; +Cc: binutils

Hi Nick,

> since this is a group all about binutils, i hope i'm at the right place for my
> question.

It is.

> the problem starts at the basics: no matter how much i've looked in the
> interwebs, i still don't understand i386-opc.tbl. for example, i don't know what
> the parts of this line mean: "mov, 2, 0xc6, 0x0, 1, 0, W|Modrm|No_sSuf|No_ldSuf,
> { Imm8|Imm16|Imm32|Imm32S,
> Reg8|Reg16|Reg32|Reg64|Byte|Word|Dword|Qword|Unspecified|BaseIndex|Disp8|Disp16|
> Disp32|Disp32S
> }".

That would be because there is no documentation.  The source code is the 
documentation.  (And of course it is so well written that it needs no 
documentation... :-)

Since i386-opc.tbl is not a C source file, the first place to look is 
the Makefile.am file in the opcodes directory.  There you will find that 
i386-opc.tbl is an input file to a generator program built from the 
i386-gen.c source file.  So read that file and work out how the 
generator works.

> ok, "mov" is the mnemonic, "2" is (guess) the number of operands, in
> brackets the type of operands accepted (not all of them clear), but what about
> the two hexadecimal values, the "1" and "0"(if not "0" then something like
> "Cpu386", "Cpu64"), "No_*Suf"?

Look at the body of the process_i386_opcodes() function in i386-gen.c. 
There you see that from each line it reads a name, followed by a slot 
number in a hash table.  The rest of the line is saved in this hash 
table slot for later processing (by output_i386_opcode).

> one further question would be, do i have to change other files as well (e.g.
> i386-opc.h, i386-init.h etc)?

No - but - you do need to configure your build tree with maintainer mode 
enabled, so that changes to i386-opc.tbl will trigger an automatic 
regeneration of files like i386-opc.h.  Ie when you are configuring your 
binutils build add:

    <path-to-sources>/configure ... --enable-maintainer-mode ...

Cheers
   Nick

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-09-27 11:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-17 17:50 Custom Instructions Nick
2010-09-17 19:57 ` Ian Lance Taylor
2010-09-17 21:08   ` Nikolaos Ikonomakis
2010-09-27 11:05 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).