flat assembler
Message board for the users of flat assembler.
Index
> Main > lea with if statement? |
Author |
|
revolution 18 Mar 2009, 04:41
mov eax,ecx also works, it also doesn't change any flags. Plus, t is one byte shorter and has better scheduling than lea
|
|||
18 Mar 2009, 04:41 |
|
Azu 18 Mar 2009, 04:46
Thanks, updated the example. Still have the same question, though. Any answers would be appreciated.
|
|||
18 Mar 2009, 04:46 |
|
revolution 18 Mar 2009, 04:49
Do you mean how to use the macro ".if"? Or the assembler "if"?
Basically the code you show above looks fine to me. jcc is really all that is available on x86 unless you want to delve into cmovcc. |
|||
18 Mar 2009, 04:49 |
|
Azu 18 Mar 2009, 04:51
What I meant was;
Please post the code using if statements instead of cmp and jb, that generates the code in the first example. I can not figure it out. For FASM, not jcc. |
|||
18 Mar 2009, 04:51 |
|
revolution 18 Mar 2009, 04:55
Okay, so I think you want to use the ".if" macro set.
Code: include "if.inc" ;comes with the windows package download .if eax,b,ebx ;do something .else ;do something else .endif |
|||
18 Mar 2009, 04:55 |
|
Azu 18 Mar 2009, 05:00
Azu wrote: What is the equivalent using an if statement? I can't figure it out. Thought there was some kind of trick to it and I was just doing something wrong. Guess it's just impossible afterall? |
|||
18 Mar 2009, 05:00 |
|
revolution 18 Mar 2009, 05:03
Well, I presume it works like this:
Code: include "if.inc" ;comes with the windows package download .if eax,nb,ebx mov eax,ecx dec eax sub edx,eax .else mov eax,ecx .endif |
|||
18 Mar 2009, 05:03 |
|
revolution 18 Mar 2009, 05:04
BTW: The .if macros just generate what you wrote in the first post. There is no magic, unfortunately.
|
|||
18 Mar 2009, 05:04 |
|
Azu 18 Mar 2009, 05:05
I was just wondering if code like
Code: cmp eax,ebx mov eax,ecx jb @f dec eax sub edx,eax @@: Code: cmp eax,ebx jb @f mov eax,ecx dec eax sub edx,eax jmp blahblah @@: mov eax,ecx blahblah: |
|||
18 Mar 2009, 05:05 |
|
revolution 18 Mar 2009, 05:11
I see, I am not expert with these macro but as far as I can tell you will only get the bloated version.
I would suggest that if you are interested in making efficient code for things like the above that using .if/.else/.endif structures is not the best way. Manual coding is always going to give at least as good and sometimes better. |
|||
18 Mar 2009, 05:11 |
|
LocoDelAssembly 18 Mar 2009, 06:20
Code: cmp eax, ebx mov eax, ecx .if ~CARRY? dec eax sub edx, eax .endif |
|||
18 Mar 2009, 06:20 |
|
Azu 18 Mar 2009, 06:33
Thanks guys
|
|||
18 Mar 2009, 06:33 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.