PDA

View Full Version : Ambiguity


dipgoswami
11-04-05, 06:01 AM
I have written the following IsoMax Program :

SCRUB

DECIMAL

LOOPINDEX CYCLE-COUNTER 100 CYCLE-COUNTER END EEWORD

MACHINE ROTATE EEWORD
ON-MACHINE ROTATE
APPEND-STATE MOVE_1 EEWORD
APPEND-STATE MOVE_2 EEWORD
APPEND-STATE MOVE_3 EEWORD

IN-STATE MOVE_1
CONDITION TRUE
CAUSES
CYCLE-COUNTER VALUE 12 + .
THEN-STATE MOVE_3
TO-HAPPEN IN-EE

IN-STATE MOVE_1
CONDITION TRUE
CAUSES
CYCLE-COUNTER VALUE 11 + .
THEN-STATE MOVE_2
TO-HAPPEN IN-EE

IN-STATE MOVE_2
CONDITION CYCLE-COUNTER COUNT
CAUSES
CYCLE-COUNTER VALUE 2 + .
THEN-STATE MOVE_1
TO-HAPPEN IN-EE

IN-STATE MOVE_3
CONDITION TRUE
CAUSES
CYCLE-COUNTER VALUE 3 + .
THEN-STATE MOVE_1
TO-HAPPEN IN-EE

: MAIN

MOVE_1 SET-STATE
INSTALL ROTATE

; EEWORD

HEX 3C00 AUTOSTART MAIN
SAVE-RAM

The Output of the program :
11 2 11 2 11 2 ......

I am unable to explain the output. Because it should be ambiguous.
Can anybody explain me the answer?

Thanks,
Dip

RMDumse
11-04-05, 09:32 AM
The Output of the program :
11 2 11 2 11 2 ......

I am unable to explain the output. Because it should be ambiguous.
Can anybody explain me the answer?

Notice you have two transitions on MOVE_1 and both of them are valuated with a condition of TRUE. When the transitions are defined, they are linked in a list to the state they are assigned "IN-STATE MOVE_1" which means there remains one fixed entry point to evaluate MOVE_1 transitions. That being in this case the latest transition, which evaluates true and executes.

The transistion CAUSES portion of the transition executes, 0 + 11 is printed. The state is changed for the next go. As soon as any transition fires, no other transitions of that state are evaluated. The "THEN-STATE" causes the active state to change, in this case, MOVE_2.

In MOVE_2, the conditional clause uses a counter, CYCLE-COUNTER, that counts from (an undefined starting point, therefore) 0 to (a specified END) count of 100. When this counter is not at the terminal count, COUNT returns a false boolean to the CONDITION and the transition is exited. So, for the next 100 times SCHEDULE-RUNS (via INSTALL) calls ROTATE, nothing but the counting happens.

When the terminal count finally occurs from executing COUNT, the CYCLE-COUNTER is reset to its inital value, 0, and the boolean returned is true. The transistion CAUSES portion of the transition executes, 0 + 2 is printed, and the next state is set to be MOVE_1.

So the printed sequence is "11" from one pass through MOVE_1 and "2" after 100 passes through MOVE_2, then back again.

dipgoswami
11-04-05, 11:12 AM
Thanks a lot!