1.5 Boolean Values


1.5 Boolean Values

HLA and the HLA Standard Library provides limited support for boolean objects. You can declare boolean variables, use boolean literal constants, use boolean variables in boolean expressions, and 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 one; HLA represents false using the value zero. Most programs treat zero 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 eight-bit values. Furthermore, as long as you ensure that your boolean variables only contain zero and one (for false and true, respectively), you can use the 80x86 and, or, xor, and not instructions to manipulate these boolean values (we'll describe these instructions a little later in this text).

You can print boolean values by making a call to the stdout.put routine, e.g.,

 stdout.put( BoolVar ) 

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




The Art of Assembly Language
The Art of Assembly Language
ISBN: 1593272073
EAN: 2147483647
Year: 2005
Pages: 246
Authors: Randall Hyde

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net