Section 8: Program Branching and Controls

99

In this way, a program can accommodate two different modes of input, such as degrees and radians, and make the correct calculation for the mode chosen. You set a flag if a conversion needs to be made, for instance, and clear it if no conversion is needed.

Suppose you had an equation requiring temperature input in degrees Kelvin, although sometimes your data might be in degrees Celsius. You could use a program with a flag to allow either a Kelvin or Celsius input. In part, such a program might include:

´bC Start program at ―C‖ for degrees Celsius.

"7Flag 7 cleared (=false).

t1

´Start program at ―D‖ for degrees Kelvin.

F7

Flag 7 set (=true).

´b1

(Assuming temperature in X-register.)

?7

Checks for flag 7 (checks for Celsius or Kelvin

 

input).

t2

If set (Kelvin input), goes to a later routine, skipping

 

the next few instructions.

2

If cleared (Celsius input), adds 273 to the

7

value in the X-register, since °K = °C + 273.

3

 

+

 

´b2

Calculation continues for both modes.

 

The System Flags: Flags 8 and 9

Flag 8. Setting flag 8 will activate Complex mode (described in section 11), turning on the C annunciator. If another method is used to activate Complex mode, flag 8 will automatically be set. Complex mode is deactivated only by clearing flag 8; flag 8 is cleared in the same manner as the other flags.