HP (Hewlett-Packard) IA-64 Computer Accessories User Manual


 
9-2 Command Files Copyright © 2000 Hewlett-Packard Co.
Ski IA-64 Simulator Reference Manual 1.0L
example of using goto and a label is:
loop:
... other commands ...
goto loop
9.2.2 The if Command
The if command allows for conditional execution. If the expression following the command evaluates to nonzero, the
remainder of the line is executed; otherwise it is ignored. (No spaces are allowed in the expression.) For example, this
command file steps through a IA-64 application-mode simulation 600 instructions at a time until the program finishes,
printing the contents of general register 32 after each step:
loop:
step 600
eval r32
if !$exited$ goto loop
quit
If a colon surrounded by spaces is present on the line, the remainder of the line is taken to be an “else” clause. That is, if
the if expression evaluates to nonzero, the remainder of the line up to but not including the colon is executed; if zero, that
part of the line is ignored and execution continues immediately following the colon. For example, the following command
file line sets the contents of general register 4 to zero or one depending on whether the sum of the contents of general inte-
ger 1 and 2 are equal to the contents of the location pointed to by general register 13.
if (r1+r2)==*r13 = r4 0 : = r4 1
9.3 Comments in Command Files
To document command files, you can add comments– any characters following an octothorpe (also called a “pound sign”
or “sharp sign” and shown, typically, as #”) are ignored by the command interpreter. Examples of comments are in
Figure 9-1.
9.4 An Example Command File
Command files are easy to write. The command file in Figure 9-1 for computing Fibonacci numbers was written in less
than five minutes and most of that time was spent making the comments correct.