From: cmk128 on
Hi
I think i need to place the same value to DS and SS, to make the
stack segment and data segment in the same location. The reason is that
c++ uses "push" instruction to push the parameter to stack before
calling a function, but it won't use a "pop" instruction to pop them
out in the function call, instead, it accesses the stack through the
DS. Am i fully correct?

But do we necessary to put the same value for CS and DS/SS? because i
found this:

char blockCaches[163840];
unsigned long long blockIDCaches[CACHE_SIZE_IN_BLOCK];

PFS_Main::PFS_Main()
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
blockCaches[0]=0x12;
3: c6 05 00 00 00 00 12 movb $0x12,0x0
blockCaches[1]=0x34;
a: c6 05 01 00 00 00 34 movb $0x34,0x1
}
11: 5d pop %ebp
12: c3 ret
13: 90 nop

Here i declare a char array outside the class, when i access the first
component of the array, i am acessing the memory location 0x0, if the
DS and CS is located at the same place, then it will have trouble.
thanks
from Peter (cmk128(a)hotmail.com)

From: greg.johnston on
__cdecl convention for x86:

push arg1
push arg2
call _procedure

_procedure:
push ebp
mov ebp,esp
; Body code example
mov eax,[ebp+8] ; First argument -> EAX
; End body
pop ebp
ret

 | 
Pages: 1
Prev: the first cpu
Next: DLLs in HLA