Re: Jit Implementation

"bartc" <bartc@freeuk.com>
Tue, 23 Mar 2010 11:53:27 -0000

          From comp.compilers

Related articles
[6 earlier articles]
Re: Jit Implementation herron.philip@googlemail.com (Philip Herron) (2010-03-21)
Re: Jit Implementation jthorn@astro.indiana-zebra.edu (Jonathan Thornburg \[remove -animal to reply\]) (2010-03-21)
Re: Jit Implementation cr88192@hotmail.com (BGB / cr88192) (2010-03-21)
Re: Jit Implementation herron.philip@googlemail.com (Philip Herron) (2010-03-21)
Re: Jit Implementation barry.j.kelly@gmail.com (Barry Kelly) (2010-03-22)
Re: Jit Implementation bartc@freeuk.com (bartc) (2010-03-23)
Re: Jit Implementation bartc@freeuk.com (bartc) (2010-03-23)
Re: Jit Implementation cr88192@hotmail.com (cr88192) (2010-03-23)
Re: Jit Implementation cr88192@hotmail.com (BGB / cr88192) (2010-03-23)
Re: Jit Implementation bartc@freeuk.com (bartc) (2010-03-24)
Re: Jit Implementation cr88192@hotmail.com (BGB / cr88192) (2010-03-26)
Re: Jit Implementation bartc@freeuk.com (bartc) (2010-03-28)
Re: Jit Implementation cr88192@hotmail.com (BGB / cr88192) (2010-03-28)
| List of all articles for this month |
From: "bartc" <bartc@freeuk.com>
Newsgroups: comp.compilers
Date: Tue, 23 Mar 2010 11:53:27 -0000
Organization: Netfront http://www.netfront.net/
References: 10-03-054 10-03-060 10-03-071
Keywords: code, architecture
Posted-Date: 23 Mar 2010 23:52:08 EDT

"Philip Herron" <herron.philip@googlemail.com> wrote in message
> bartc wrote:


>> program[0] = 0xB8; /* mov eax,1234h */ program[1] =
>> 0x34; program[2] = 0x12; program[3] = 0; program[4] = 0; program[5]
>> = 0xC3; /* ret */


> *(c_buffer) = 0xB8; /* mov eax,1234h */
> *(c_buffer+1) = 0x34;
> *(c_buffer+2) = 0x12;
> *(c_buffer+3) = 0;
> *(c_buffer+4) = 0;
> *(c_buffer+5) = 0xC3; /* ret */
>
> fnptr = (int (*)(void)) c_buffer;
> retval = fnptr( ); /* call the code */
>
> printf("Result = %X\n", retval ); /* show result */
> munmap( c_buffer, c_len );
>
> return 0;
> }
>
> Hope some may find it useful. Have you any good pointers to references
> for the operand values for this instruction set? I guess its in the
> intel manuals but which ones are most useful or relevant?


I find modern Intel docs impossible.


The simplest I've found to be the original Intel datasheets for 8086 and
80186:


http://www.datasheetarchive.com/pdf-datasheets/Datasheets-14/DSA-279540.pdf


http://www.datasheetarchive.com/pdf-datasheets/Datasheets-308/23658.pdf


There's one for the 8087 too. These are mostly about hardware but a table
near the end gives the instructions sets.


Obviously these are for 16-bits, but most of the important stuff is in
there, beautifully laid out.


For 32-bits (80386 and up), nothing much actually changes (ignoring MMX and
SIMD and all that): operating in 32-bit address and 32-bit data mode:


* 'w' word mode in the datasheets actually means 32-bits (for 16-bits, use
the data override prefix byte, I think 66H).
* Address modes are different, and can use an SIB byte. The secrets of MODRM
and SIB had to be gleaned from other sources (one of these was the NASM.TXT
file that used to be part of the Nasm download. Beware of one or two errors
though.)


Also comp.lang.asm.x86 is a useful resource for this sort of question.


--
Bartc


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.