Wiki

Clone wiki

Super-Mon / Short_flow_of_control

SHORT: FLOW OF CONTROL

IN SHORT THERE ARE TWO WAYS (IN ADDITION
TO JSR, JMP, AND OTHER 6502 BRANCHES) TO
AFFECT THE FLOW OF THE PROGRAM.

FIRST IS "IFT":

#8000: NUMBER=1
# IFT(NUMBER>1,*)
# PRSTR("FOO")
#X

HERE WE STICK 1 INTO A VARIABLE, THEN
WE USE THE "IFT" LIBRARY FUNCTION TO
TEST ITS VALUE AND BRANCH IF IT'S MORE
THAN 1. WHICH IT'S NOT, SO THE BRANCH IS
NOT TAKEN, SO "FOO" IS *NOT* PRINTED.

NOTE HOW WE MADE A FORWARD BRANCH... THE
NORMAL WAY IN SUPER-MON: USE "*" AS A
PLACEHOLDER, THEN REPAIR IT LATER USING
THE "X" COMMAND.

HERE'S THE SHORT WAY TO DO A LOOP:

#8000: NUMBER=1
# ;PRINT THE NUMBERS 1 TO 9
# LOOP()
# PRDEC(NUMBER)
# WHILE(STEP(NUMBER,1,10))
# RTS

THE "LOOP" FUNCTION MARKS THE START OF
YOUR LOOP, AND "WHILE" MARKS THE END. IT
WILL EXECUTE ONCE, AND THEN LOOP AGAIN
IF THE CONDITION IS TRUE.

IN THIS CASE OUR CONDITION MAKES USE OF
"STEP" WHICH INCREMENTS A VARIABLE BY
SOME NUMBER, THEN CHECKS IF THE RESULT
IS LESS THAN ANOTHER NUMBER.

ALSO NOTE THAT SHORT ENCOURAGES COMMENTS
IN YOUR CODE: JUST START THEM WITH A
";" MARKER.

This page is from Super-mon's built-in help system.

Updated