Thursday, July 8, 2010

Register EDI holds the bit offset ...


software | Windows |








EDI: The Destination Index

Every loop that generates data must store the result in memory, and
doing so requires a moving pointer. The destination index, EDI, is that
pointer. The destination index holds the implied write address of all
string operations. The most useful string instruction, remarkably
enough, is the seldom-used STOS. STOS copies data from the
accumulator into memory and increments the destination index. This
one-byte instruction is perfect, since the final result of any calculation
should be in the accumulator anyhow, and storing results in a moving
memory address is a common task.

source :
http://www.swansontec.com/sregisters.html


software | GNU/Linux |




(gdb) info registers
rax 0xfffffffffffffdfc -516
rbx 0x5dc 1500
rcx 0xffffffffffffffff -1
rdx 0x5dc 1500
rsi 0x1 1
rdi 0x7fffedb60c40 140737181518912
rbp 0x23c7160 0x23c7160
rsp 0x7fffedb60bf0 0x7fffedb60bf0
r8 0x0 0
r9 0xffffffff 4294967295
r10 0x8 8
r11 0x246 582
r12 0x7fffedb60c40 140737181518912
r13 0x7fffedb60c50 140737181518928
r14 0x0 0
r15 0x1 1
rip 0x7fc4a09070c8 0x7fc4a09070c8 <*__GI___poll+24>
eflags 0x246 [ PF ZF IF ]
cs 0x33 51
ss 0x2b 43
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
(gdb)

rdi 0x7fffedb60c40 140737181518912



The RAX, RBX, RCX, RDX, RBP, RSI, RDI, and RSP registers are used by
both 32-bit and 64-bit binaries. However, in 32-bit mode, only the low
32 bits of these registers are accessible by 32-bit binaries. In the x86
architecture, these registers are EAX, EBX, ECX, EDX, EBP, ESI, EDI,
and ESP.

source :
http://developers.sun.com/solaris/articles/x64_dbx.html



| Related Discussion |



knut st. osmundsen 2007-02-09 18:29:55 EST
Description of problem:

Crashing at __lll_mutex_timedlock_wait+148 (/lib64/tls/libpthread.so.0):
lock cmpxchg %edx,(%rdi)
Because the syscall wasn't made and %rdi hasn't been loaded with %r12
yet.
Version-Release number of selected component (if applicable):
glibc-3.4.0
How to fix:
Move the mov %r12,%rdi instruction up somewhere before the je 8f.

How to reproduce:

This isn't easy to reproduce and I'm not going to write a testcase for it
since it's a very obvious bug in the code. But, my from the situation I
get it in is that it requires a 2nd thread to signal the condition variable
/mutex (I'm not quite sure which it is) while the crashing thread is
engaging a sleep.


source :
https://bugzilla.redhat.com/show_bug.cgi?id=228103



| Variation |



Hardware 64 bit.
Windows OS 32 bit so uses EDI.
GNU/Linux 64 bit version so used RDI.

Links(s).
http://archive.midrange.com/wdsci-l/200903/msg00083.html