News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

.IF .ELSE

Started by shaldan, October 31, 2005, 09:49:14 AM

Previous topic - Next topic

shaldan

hello ...  can you tell me, what "pure" assembler code produces ?:


.if condition
blablabla statements
.else
another blablabla statements
.endif




PBrennick

shaldan,


    cmp condition1. eax  ; or similar
    jne  nextcheck

    .... code that goes here is for 'condition is met'
    jmp nextroutine

nextcheck:
    cmp condition2. eax  ; or similar
    jne  nextroutine

    .... code that goes here is for 'condition is met'

nextroutine:



This is untested coe just to show you what a possible layout could be.
Paul
The GeneSys Project is available from:
The Repository or My crappy website

Mirno

From the list file:

00000000 .code
00000000 start:
    .if eax
00000000  0B C0    *     or eax, eax
00000002  74 04    *     je     @C0001
00000004  0B C0         or  eax, eax
    .else
00000006  EB 02    *     jmp    @C0003
00000008    *@C0001:
00000008  23 C0         and eax, eax
    .endif
0000000A    *@C0003:
end start


The lines with a * are generated, those without are actual lines from the .asm file.

Mirno

shaldan

thanx ... I thought it could be something like this.

In the NeHe openGl tutorials (MASM source) I found this:


.IF (fullscreen)
                 mov fullscreen, 0
                .ELSE
                 mov fullscreen, 1
                .ENDIF


and I think there are too many statements. I replaced it with:


mov eax,1
xor eax,fullscreen


and it works well.
In comparison with .if else it looks faster and smaller ... am I right or not ? :)
How can a programmer counts cycles ? .. simply handly by knowing how many cycles are needed or is there a more comfortable way ?



Eugen


Hi shaldan

The simplest way is 'xor fullscreen,1'
Btw, you are not modifying the 'fullscreen' variable in your optimization, only eax :D.

Eugen

shaldan

hehe ... my fault .. i forgot to past following code, where there is a procedure using the xored eax :)

But xor fullscreen,1 is even better :)) thanks ... (I thought xor must use register as destination)


diablo2oo2

Quote from: shaldan on October 31, 2005, 09:49:14 AM
hello ...  can you tell me, what "pure" assembler code produces ?:


.if condition
blablabla statements
.else
another blablabla statements
.endif



you can find this out yourself. just load your compiled programm into a disassembler and see what happens.