6.2. HEXNUM2: Using Logical Masks

We will now apply logical masking and a shift instruction to the HEXNUM program (Figure 4-3). In this new version, shown in Figure 6-1, we will encode the input digits as ASCII characters and store them in memory, using a null byte to terminate the string.

This program illustrates the instruction types just introduced while presenting programming techniques that will continue in future examples.

Character strings are typically stored in memory with a NUL character (Table 2-3) marking their end. This allows the processing of strings of arbitrary length by first testing each byte against zero (NUL). Thus the loop in HEXNUM2 is of the form while <nonzero> do…, requiring a predicated exit branch at the top and an ...

Get Itanium® Architecture for Programmers: Understanding 64-Bit Processors and EPIC Principles now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.