Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

Chapter 1. HELLO, WORLD OF ASSEMBLY LANG... > 1.7 An Introduction to the Intel 80×... - Pg. 6

HELLO, WORLD OF ASSEMBLY LANGUAGE 6 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 demon- strates some typical declarations: static BoolVar: HasClass: IsClear: boolean; boolean := false; 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 80×86 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.