flat assembler
Message board for the users of flat assembler.
Index
> Main > How "expensive" is the conditional operations |
Author |
|
drobole 14 Nov 2010, 04:23
I was looking at the IF.INC file and was wondering how expensive in regard to CPU instructions these macros are compared to regular jumping
Anyone know? |
|||
14 Nov 2010, 04:23 |
|
drobole 14 Nov 2010, 10:54
If they don't produce redundant instructions in circumstances like this
Code: stdcall strcompare, dbuf, cbuf, sizeof.dbuf .if ecx = 0 ccall printf, w_equal, ecx .else ccall printf, w_not_equal, ecx .endif Im happy. That makes them very useful indeed |
|||
14 Nov 2010, 10:54 |
|
baldr 15 Nov 2010, 17:53
drobole,
That will be equivalent to Code: stdcall strcompare, dbuf, cbuf, sizeof.dbuf ;.if ecx = 0 cmp ecx, 0 jne ..else?0; generated unique symbol ccall printf, w_equal, ecx ;.else jmp ..endif?1; another generated unique symbol ..else?0: ccall printf, w_not_equal, ecx ;.endif ..endif?1: |
|||
15 Nov 2010, 17:53 |
|
drobole 16 Nov 2010, 22:29
Quote:
I was thinking about how higher level language compilers tend to generate redundant assembly instructions. At least on the first pass. After all, optimizing a compiler is much about reducing, factoring and simplifying the assembly instructions generated. I wasn't sure how assemblers and their macros go about stuff like that, but since assembly instructions for the most part correspond to a single machine instruction I guess there is not much room for redundant code being generated anyway. Also, I'm not all that used to assembly at this point. I just dislike all the labels/jumps you need in order to facilitate a if,else if, else if etc. Especially when you get loops and stuff inside those. Coming from C, this is kinda hard to swallow. But maybe I'll get used to it |
|||
16 Nov 2010, 22:29 |
|
vid 16 Nov 2010, 23:40
drooble: Outside the extremely time critical pieces of code (eg. crypto algorithms, distributed computations, etc.) you can freely use them, difference would be hardly measurable .
But if you want to learn assembly, I'd suggest you to first learn how to go on without these macros (get accustomed to "linear" source code layout), and only start using macros after you understand well what they do. |
|||
16 Nov 2010, 23:40 |
|
drobole 17 Nov 2010, 09:12
Sounds like a good idea. Thanks guys
|
|||
17 Nov 2010, 09:12 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.