flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > push ecx+1 trashes ebx?

Author
Thread Post new topic Reply to topic
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 29 Apr 2009, 21:17
"push ecx+1" is trashing ebx, why?? Is there a way to make it trash something else instead?




Edit: actually I'm not sure WHAT it's trashing.

It crashes my program even if I preserve every single register;

Code:
pushad
push    ecx+1
add    esp,4
popad    


Why??


P.S. if I remove the +1 it is fine.
Post 29 Apr 2009, 21:17
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 29 Apr 2009, 21:38
Code:
00401001   60               PUSHAD
00401002   51               PUSH ECX
00401003   6A 01            PUSH 1
00401005   83C4 04          ADD ESP,4
00401008   61               POPAD

    


"push ECX+1" is not the equivalent of push ecx/lea ecx,[ecx+1]/xchg ecx, [esp] but push ecx/push +1 instead.

push and pop supports an arbitrary number of operands without comma separation
Post 29 Apr 2009, 21:38
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 29 Apr 2009, 21:44
Thanks ^^ that explains a lot.
Post 29 Apr 2009, 21:44
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.