News:

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

TRUE in Masm

Started by jag, January 08, 2007, 12:53:59 AM

Previous topic - Next topic

jag

I am trying to make a dll.
I follow the tutorial here: http://win32assembly.online.fr/tut17.html

I get this error: error A2006: undefined symbol : TRUE

Is the tutorial outdated and the constant TRUE has been removed from MASM? or is there something I did wrong?

Thanks.

hutch--

These two values have been defined in the WINDOWS.INC file since it was first created. They are specified in the SDK from Microsoft under win32.


TRUE                                 equ 1
FALSE                                equ 0
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jag

Aye, dumb me.
I forgot to include windows.inc

Thank you Hutch. Originally I thought TRUE and FALSE were just built into MASM but now that I think about it that wouldn't make sense since in some cases FALSE could be 0 and in others, -1 but in Windows it's always one convention.

gabor

Hello!

Just a footnote: traditionally 0 is FALSE and any other value, so 1 too, is TRUE. That's why checking against 0 is also okay for logical testing. Comparing with 0 can be replaced when using registers by the OR operation. Like

    cmp al,TRUE   ; this sets Z if al was TRUE (match)
    jz @F
    ; al was false
    ...
@@:
    ; al was true

This does the same:
    or al,al   ; this set Z if al was 0 (0 or 0 = 0)
    jnz @F
    ; al was false
    ...
@@:
    ; al was true


Greets, Gábor

Rockoon

The 'safest' way to generate these values in most languages is with the idea that:

false = 0

and thus

true = (false == 0)

...it no longer matters what the underlying datatype is, or even that true is loosely or strictly defined.

There are many conventions for 'true' because they all happen to be usefull in one form or another. The '-1' crowd likes true to be part of masking operations, while the '1' crowd likes true to be more fluently used as an index or single bit.

When C++ compilers can be coerced to emit rcl and rcr, I *might* consider using one.