This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Custom Instructions
- From: Nick Clifton <nickc at redhat dot com>
- To: Nick <nikos_ikono1989 at yahoo dot gr>
- Cc: binutils at sources dot redhat dot com
- Date: Mon, 27 Sep 2010 12:05:08 +0100
- Subject: Re: Custom Instructions
- References: <loom.20100917T183923-657@post.gmane.org>
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