<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2523" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>X86 is a little endian machine so <FONT 
face="Times New Roman" size=3>e9 bd ff  -> JMP relative 0xFFBD or JMP 
relative -0x43 (i might be of by one ...)  = -67 decimal (64 for the 
nops and 3 for the e9 bd ff ) its is relative to the next instruction if i 
remember right ...</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>greetings,</FONT></DIV>
<DIV><FONT face=Arial size=2>todthgie</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A title=shadravan_f@yahoo.com href="mailto:shadravan_f@yahoo.com">Shadravan 
  Fontanov</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A title=linuxbios@linuxbios.org 
  href="mailto:linuxbios@linuxbios.org">linuxbios@linuxbios.org</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Friday, June 29, 2007 19:03</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> [LinuxBIOS] General question 
  abouts jumps in machine code</DIV>
  <DIV><BR></DIV>Hello,<BR><BR>I wanted to verify that the relative jump in my 
  program is properly transalated into machine code.<BR>Consider following 
  example:<BR><code begins><BR>extern char handler[], 
  endhandler[];   /* C-code glue for the asm insert 
  */<BR>asm(<BR>    ".data\n"<BR>    
  ".code16\n"<BR>    ".globl handler, 
  endhandler\n"<BR>    "\n"<BR>    
  "handler:\n"<BR>    "nop\n" "nop\n" "nop\n" "nop\n" "nop\n" 
  "nop\n" "nop\n" "nop\n"<BR>    "nop\n" "nop\n" "nop\n" "nop\n" 
  "nop\n" "nop\n" "nop\n" "nop\n"<BR>    "nop\n" "nop\n" "nop\n" 
  "nop\n" "nop\n" "nop\n" "nop\n" "nop\n"<BR>    "nop\n" "nop\n" 
  "nop\n" "nop\n" "nop\n" "nop\n" "nop\n" "nop\n"<BR>    "nop\n" 
  "nop\n" "nop\n" "nop\n" "nop\n" "nop\n" "nop\n" "nop\n"<BR>    
  "nop\n" "nop\n" "nop\n" "nop\n" "nop\n" "nop\n" "nop\n" 
  "nop\n"<BR>    "nop\n" "nop\n" "nop\n" "nop\n" "nop\n" "nop\n" 
  "nop\n" "nop\n"<BR>    "nop\n" "nop\n" "nop\n" "nop\n" "nop\n" 
  "nop\n" "nop\n" "nop\n"<BR>    "jmp 
  handler\n"<BR>    "endhandler:\n"<BR>    
  "\n"<BR>    ".text\n"<BR>    
  ".code32\n"<BR>);<BR><BR>int main(void) <BR>{<BR>    return 
  0;<BR>}<BR><code ends><BR><BR>There are 64 NOPs, on the basis of these I 
  want to locate my jmp instruction after compiling. I am interested about "jmp 
  handler\n"-instruction.<BR><BR>I compile the example above, then 
  start<BR> hexdump -vC compiled_example | less<BR>and look for 64 times of 
  0x90 (opcode for NOP). I find them:<BR><snippet of hexdump 
  starts><BR>00005740  00 00 00 00 00 00 00 00  84 e5 04 08 90 90 
  90 90  |................|<BR>00005750  90 90 90 90 90 90 90 90  
  90 90 90 90 90 90 90 90  |................|<BR>00005760  90 90 90 90 
  90 90 90 90  90 90 90 90 90 90 90 90  
  |................|<BR>00005770  90 90 90 90 90 90 90 90  90 90 90 90 
  90 90 90 90  |................|<BR>00005780  90 90 90 90 90 90 90 
  90  90 90 90 90 e9 bd ff 00  |................|<BR>00005790  00 
  00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  
  |................|<BR><snippet of hexdump end><BR>Exactly 64 times 0x90, 
  fine... The next code after the last 0x90 is 0xe9. Look at "Intel Architecture 
  Software Developers Manual Vol2" tells: its jump instruction, the next two 
  bytes (bd ff) specify the relative address to jump. bdff must be  in 
  second complement and  represent  minus 4201. But offset 4201 does 
  not jumps to the start of the NOP sequence, it jumps to a very smaller 
  address...<BR><BR>Do you have any 
  hints?<BR><BR>Regards<BR><BR>Shadravan<BR><BR>
  <P>
  <HR SIZE=1>
  Be a better Globetrotter. <A 
  href="http://us.rd.yahoo.com/evt=48254/*http://answers.yahoo.com/dir/_ylc=X3oDMTI5MGx2aThyBF9TAzIxMTU1MDAzNTIEX3MDMzk2NTQ1MTAzBHNlYwNCQUJwaWxsYXJfTklfMzYwBHNsawNQcm9kdWN0X3F1ZXN0aW9uX3BhZ2U-?link=list&sid=396545469">Get 
  better travel answers </A>from someone who knows.<BR>Yahoo! Answers - Check it 
  out. 
  <P>
  <HR>

  <P></P>-- <BR>linuxbios mailing 
  list<BR>linuxbios@linuxbios.org<BR>http://www.linuxbios.org/mailman/listinfo/linuxbios</BLOCKQUOTE></BODY></HTML>