LMC Conditional Structures

Teach any GCSE Computer Science class

We have put together a full GCSE Computer Science curriculum that will give you all the teaching materials you need to teach any topic.

Whether you’re a brand new Computer Science teacher, or you’ve been teaching ICT for years, our resources will save you hours and hours of lesson preparation every single week.

View the resources →

The following program will show the use of branch instructions to create an IF/ELSE/ENDIF conditional structure in a program.

Running the program: when prompted, INPUT two numbers, if they are different then the program will OUTPUT a 0 (FALSE) and if they are the same then the program will OUTPUT a 1 (TRUE),

NOTE: The 'if' label has no function and is added to aid clarity.

STA value1
SUB value1
if BRZ else
   LDA false
BRA endif
else LDA true
endif HLT
value1 DAT
true DAT 1
false . . .

This content is restricted to subscribers