1.4 Boolean Values

HLA and the HLA Standard Library provide limited support for boolean objects. You can declare boolean variables, use boolean literal constants, use boolean variables in boolean expressions, and you can print the values of boolean variables.

Boolean literal constants consist of the two predefined identifiers true and false. Internally, HLA represents the value true using the numeric value 1; HLA represents false using the value 0. Most programs treat 0 as false and anything else as true, so HLA's representations for true and false should prove sufficient.

To declare a boolean variable, you use the boolean data type. HLA uses a single byte (the least amount of memory it can allocate) to represent boolean values. The following example demonstrates some typical declarations:

static
     BoolVar:     boolean;
     HasClass:    boolean := false;
     IsClear:     boolean := true;

As this example demonstrates, you can initialize boolean variables if you desire.

Because boolean variables are byte objects, you can manipulate them using any instructions that operate directly on 8-bit values. Furthermore, as long as you ensure that your boolean variables only contain 0 and 1 (for false and true, respectively), you can use the 80x86 and, or, xor, and not instructions to manipulate these boolean values (these instructions are covered in Chapter 2).

You can print boolean values by making a call to the stdout.put routine. For example:

stdout.put( BoolVar )

This routine prints the text true or false depending upon the value of the boolean parameter (0 is false; anything else is true). Note that the HLA Standard Library does not allow you to read boolean values via stdin.get.