0

I have an assignment for school where I have an input number, and based on that input, I take the traffic controller and use different directions.

The LMC knows add, subtraction, input, output, etc. Based on my input (either 0, 5, 10, or 15) I have to do something.

What is the best way to go about working this out within LMC?

1 Answers1

0

The best way to go about this would be taking the number away from the input then using the BRZ command to figure out what is going on.

The code would look like this:

INP
STA A
BRZ LOOP1
LDA A
SUB FIVE
BRZ LOOP2
LDA A
SUB TEN
BRZ LOOP3
BRA LOOP4
LOOP1    *IF INP = 0 THEN DO SOME STUFF*
LOOP2    *IF INP = 5 THEN DO SOME STUFF*
LOOP3    *IF INP = 10 THEN DO SOME STUFF*
LOOP4    *IF INP = 15 THEN DO SOME STUFF*
A DAT
FIVE DAT 5
TEN DAT 10

Note: This code is the best representation of what one would need without further clarification of the question from the OP. Please feel free to comment any problems and I will endeavor to fix them.

Liwa
  • 116
  • 12