flat assembler
Message board for the users of flat assembler.

Index > Windows > Some Question

Author
Thread Post new topic Reply to topic
Nameless



Joined: 30 Apr 2010
Posts: 95
Nameless 12 Sep 2010, 14:07
if u got some free time to kill, let me help Very Happy
other than that close this page, cause its
BOOOOOOOORRRRRRRRRRIIIIIIIIIINNNNNNNNGGGGGGGG........


here we go:
1)
"The (ret size) instruction is very useful for implementing space efficient (and fast) calling conventions where the callee is responsible for reclaiming stack space occupied by parameters."
(http://en.wikipedia.org/wiki/X86_assembly_language#Stack_instructions)

does that mean creating my owen calling convention? like deciding which parameters go first and which go last?
or it means choosing any of the already existing calling conventions that the callee is resposible for cleaning the stack? such as fastcall, stdcall, safecall but not cdecl or syscall?
=======------------------------=======
2)
which method is better to setting up the stack frame?
Code:
enter procedure-nesting-depth, local size
    

or
Code:
push ebp
mov ebp, esp
sub esp, size
    

=======------------------------=======
3)
in question 2) is used (enter) local size is required, and if used the push, mov, sub, the size is required, what if im passing diffrent sized parameters? dword, word?
also what if i wanna pass an unknown string size? or all strings are one byte since they are defined as (db, defined byte)
=======------------------------=======
4)
what if i have a proc, and i called it using stdcall? and i didnt clean the stack at the proc and cleaned it after it returns? for example
Code:
proc _dead, lpData, lpStr
 push edx
 push ecx
.......
 ret
endp

start:
 stdcall    _dead, Data, Str
 pop                ecx
 pop             edx
    

will there be a problem in that?

and what if i did the reverse with cdecl? cleaned the stack inside the proc a and not outside it?
=======------------------------=======
5)
an OS like MikeOS, written for x86 Processors, will it run on x64 Processor ? since all custom OSes are
written under real-mode (16bit) !!!!
=======------------------------=======
6)
is that correct?

push x
push y
push z
call [function]

| |
| |
|__________|esp
| |
| z |
|__________|esp+4
| |
| y |
|__________|esp+8
| |
| X |
|__________|esp+12

so x = [esp+12]
so y = [esp+8]
so z = [esp+4]
=======------------------------=======
7)
whats the diffrence between "rep" and "loop" ?
=======------------------------=======
Post 12 Sep 2010, 14:07
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20479
Location: In your JS exploiting you and your system
revolution 12 Sep 2010, 14:21
1. Don't understand what you are asking. You can make/use whatever calling standard you want.

2. There is no such thing as better. It depends upon what you want to achieve.

3. Strings are usually passed as pointers. Generally you can't use word/byte values in a dword calling standard.

4. Unbalanced stack = bad. Don't do it. Random failures could occur at any time.

5. All current 64-bit CPUs fully support the 16bit modes.

6. No. Esp is only valid as long as you never use push, pop or any instruction that alters the stack pointer.

7. Rep only works with string instructions. Loop is a branching instruction. Do you have you the CPU manuals? If not, download them.
Post 12 Sep 2010, 14:21
View user's profile Send private message Visit poster's website Reply with quote
Nameless



Joined: 30 Apr 2010
Posts: 95
Nameless 12 Sep 2010, 14:35
3. passing a string (reserved byte) as a pointer? like:
Code:
.data
 str1 rb 1024

.code
 mov eax, str1
;or
 mov eax, dword [str1]
;or
 mov eax, dword str1

    

is thats the string pointer, which one is correct?

6. so the idea is correct as long as i don't use any instruction that alters the stack? i just mean their order, whose first and whose last and the numbers 8, 12, 16 are they correct? considering the dword is 4 bytes each?

7. now i do, i used to have just 1, but now i got the 5, gonna start looking
Post 12 Sep 2010, 14:35
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20479
Location: In your JS exploiting you and your system
revolution 12 Sep 2010, 14:41
3.
Code:
mov eax,string1 ; a pointer to string1
mov eax,dword[string1] ; the first 4 characters of string1, NOT a pointer    
6. ESP is decremented by each push, the stack grows downward. Using esp directly as an address register can be problematic, the x86 opcodes have lots of hidden registers used (e.g. enter, leave, push, pop, ret, call and others)

7. Happy reading.
Post 12 Sep 2010, 14:41
View user's profile Send private message Visit poster's website Reply with quote
Nameless



Joined: 30 Apr 2010
Posts: 95
Nameless 12 Sep 2010, 14:43
6. yea, ill move their values to variables as soon as the procedure starts, but im confused about their order, is there any simple way to remember it with? some equation maybe?

thanks alot for ur time Smile
Post 12 Sep 2010, 14:43
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20479
Location: In your JS exploiting you and your system
revolution 12 Sep 2010, 14:48
The first value pushed will have the highest numerical address.
The last value pushed will have the lowest numerical address.

But, the offsets (esp+something) are variable and changing because esp changes.
Post 12 Sep 2010, 14:48
View user's profile Send private message Visit poster's website Reply with quote
Nameless



Joined: 30 Apr 2010
Posts: 95
Nameless 12 Sep 2010, 14:54
I got it all now Smile thanks alot...
can i send u a private message? there is a couple of thing that i couldn't ask here Sad

i would have offered u a drink if u didn't live in Narnia, and thats the third time i think Very Happy
Post 12 Sep 2010, 14:54
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20479
Location: In your JS exploiting you and your system
revolution 12 Sep 2010, 14:58
My PM box is always available for people to send.
Post 12 Sep 2010, 14:58
View user's profile Send private message Visit poster's website Reply with quote
Nameless



Joined: 30 Apr 2010
Posts: 95
Nameless 12 Sep 2010, 15:04
thank you Smile
see u in another episode of
THE N00B CRAP
hehehe Very Happy
Post 12 Sep 2010, 15:04
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.