hi all,

i'm asking if someone could kindly help me on this:

i need to translate this HLL into asm :)

IF DEBUG

.IF eax == .....
...
...
...
.ENDIF

END IF

That's only couse i prefer to see asm code :)

Thanks ALL!
B7
Posted on 2002-05-22 14:09:38 by Bit7
Afternoon, Bit7

ummm....
It seems that it's already translated:grin: .

The "DEBUG" would just be declared somewhere (I usually put it at the top of the main .asm file just above the "include"s).
i.e.
.386                 ; 386 instruction set

.model flat, stdcall ; 32 bit memory model
option casemap:none ; Case sensitive

; 1 == debugging log is on.
; 0 == debugging log is off
_DEBUGON EQU 1

include \masm32\include\windows.inc
...

Then I'd use it in code like so...


IF _DEBUGON
; write message to the debugging log
invoke SetFilePointer,hDebugFile,0,0,FILE_END
invoke WriteFile,hDebugFile, OUTPUTDEBUGTEXT("prWinMain: Stopped Message Pump.") ,ADDR dwBytesWrittenDF,0
ENDIF


Cheers,
Scronty
Posted on 2002-05-22 17:03:40 by Scronty
You could also do conditional compilation this way, by defining the constant 'DEBUG' on the command line for the compiler. This is one way of making debug builds.
Posted on 2002-05-22 18:21:05 by sluggy
sorry... in this period my brain-pulse-diagram seems to be flat ! (no activity) :)

thanks !!

B7
Posted on 2002-05-23 03:34:33 by Bit7
The most important feature here, not said yet, is that if the condition is false, the code (asm) within the scope of the IF/ENDIF block is not assembled at all!!

This is why its used instead of .if/.else with a memory variable. In this case, true or false, it doesnt matter, its still evaluated at RUN-TIME and has to be compiled into code.

IF/ENDIF blocks are COMPILE-TIME conditionals...

Also, be aware they will play tricks on your head if you use them in a macro, and you get an error report on compile concerning the macro.

ie)
dumb MACRO 

mov eax, 3
xor edx, edx
IF DEBUG
mov edx, eax
mov esi, @CatStr( <ed>, <x>)
ELSE
mov edx, ebx
mov edi, SomeOtherMacro( 3 )
ENDIF
ENDM


This is just a dumb example, if the error was generated on line 4 of your macro file (and stated as such). Your macro looks like:
dumb MACRO 

1 mov eax, 3
2 xor edx, edx
IF DEBUG
3 mov edx, eax
4 mov esi, @CatStr( <ed>, <x>)
ELSE
3 mov edx, ebx
4 mov edi, SomeOtherMacro( 3 )
ENDIF
ENDM

So which 4, is 4?? Ive fallen in this trap before, and tried correcting macro code in attempt to figure out the problem, only to realize im hacking up perfectly good code (that was not included in the compile)!! :rolleyes:

:NaN:
Posted on 2002-05-23 03:55:35 by NaN
NAN, thanks for the deep help. Now it's more clear.



B7
Posted on 2002-05-23 06:31:40 by Bit7