flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
LiuGuoHua(Chinese) 06 Oct 2003, 05:14
[esp+4] or [esp+8] ??
|
|||
![]() |
|
LiuGuoHua(Chinese) 06 Oct 2003, 05:34
thx, i know what you mean.
[code] push ebp mov ebp,esp [/code] thus ebp=esp the first parameter should be [esp+08], too. right? (if there is no local var) |
|||
![]() |
|
JohnFound 06 Oct 2003, 05:48
LiuGuoHua(Chinese) wrote: thx, i know what you mean. Yes in this case first parameter will be at [esp+08] too, as long as esp=ebp at this place of the code. But what is the meaning to use [esp], when you have the right value in ebp? esp is very unstable and potentially buggy, because every push can change esp. For example: invoke arg1, arg2, arg3 - after pushing arg3 esp changes and arg2 and arg1 will have different offsets compared with offsets before invoke line. This is very hard reason to use [ebp] instead [esp]. [esp] is OK only for very small procedures. |
|||
![]() |
|
LiuGuoHua(Chinese) 06 Oct 2003, 05:58
I know !
thx very much,JohnFound! |
|||
![]() |
|
roticv 06 Oct 2003, 15:20
[esp+4] without frame stack, [ebp+8] with frame stack
|
|||
![]() |
|
aaro 07 Oct 2003, 12:17
Quote:
You can handle that easily with macros: http://board.flatassembler.net/topic.php?t=322 |
|||
![]() |
|
JohnFound 07 Oct 2003, 12:52
Hi, aaro.
I missed this post, sorry. ![]() Actually, it is interesting approach, but I still wonder, why I have to use esp? Using ebp is only too instruction more, but you have full comfort working with stack. If I need some very very fast parameter passing, I whold use register convention. In all other cases ebp is OK, without counting how many push/pop's I made. And you know - if the subroutine is slow, too instructions more or less will not make it run faster/slower. Regards. |
|||
![]() |
|
aaro 07 Oct 2003, 13:37
Biggest reason is because x86 has so few registers, with those macros you can use one more. And with those macros i don't see any disadvantages using esp, so why not?
![]() Quote:
You don't have to count anything anymore.. ![]() |
|||
![]() |
|
roticv 07 Oct 2003, 14:53
aaro wrote: Biggest reason is because x86 has so few registers, with those macros you can use one more. And with those macros i don't see any disadvantages using esp, so why not? You still need to preserve ebp if you end up using it, so not much diffference. Also you can make use of mmx registers since I think most processors have mmx now. |
|||
![]() |
|
aaro 07 Oct 2003, 15:06
roticv wrote: You still need to preserve ebp if you end up using it, so not much diffference. Also you can make use of mmx registers since I think most processors have mmx now. Yes you'r right, should have mentioned that windows wants you to preserve ebp.. Like every other registers exept eax, ecx and edx |
|||
![]() |
|
MazeGen 07 Oct 2003, 17:31
There may be one more reason for the EBP: instructions using the EBP as base are shorter (they don't need SIB byte in opcode):
Code: 8B4508 MOV EAX,[EBP+8] 8B442408 MOV EAX,[ESP+8] |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.