Mail Archives: djgpp/1997/04/13/12:35:36
From: | nitehawk91 AT aol DOT com
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | DJGPP stack when calling a function? Please help.
|
Date: | 13 Apr 1997 11:15:10 GMT
|
Organization: | AOL Bertelsmann Online GmbH & Co. KG http://www.germany.aol.com
|
Lines: | 47
|
Message-ID: | <19970413111500.HAA07345@ladder01.news.aol.com>
|
NNTP-Posting-Host: | ladder01.news.aol.com
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Greetings !
I have a problem accessing function parameters from an Assembler module.
Could someone please explain to me how the paramers of an function are pushed onto the stack with DJGPP ?
The basic idea I have (from the cofftest.asm that came with nasm) is :
parameters;
return address; 4 bytes
stack pointer ; 4 bytes
I have a function that looks like this : func(short, short, short)
Now the stack would look like :
short 3; 2 byte
short 2; 2 byte
short 1; 2 byte
return adress ; 4 byte
stack pointer ; 4 bytes
Now I tied to access the three parameters as following :
mov eax, [esp+8] ; short 1 to eax
mov ebx, [esp+10] ; short 2 to ebx
mov ecx, [esp+12] ; short 3 to ecx
This compiles and the programm works fine, but I get idiotic results.
(BTW : The assembler function doesn't return a value)
Whats going wrong here ?
2. Pointer access problem :
assume I have char string[] = {'h','e','l','l','o'};
In C I could access the 'e' for example with string[1] or *(string+1).
How can I make this in Nasm ?
I have declared [EXTERN _string]
Tried to access the 'e' with mov eax,[_string+1]
This doesn't work also. Why ?
Please help me.
Thank's
Matthias
<NiteHawk91 AT aol DOT com>
*Aritficial intelligence is better than natural stupidity
- Raw text -