RosettaCodeData/Task/Conditional-structures/LC3-Assembly/conditional-structures-2.lc3

20 lines
422 B
Plaintext

.orig x3000
LD R1, x ; get x
LD R2, y ; get y
NOT R0, R2 ; R0 = ~y
ADD R0, R0, 1 ; R0 = -y
ADD R0, R0, R1 ; R0 = x - y
BRZ BRANCH ; if (x == y) { go to BRANCH }
LEA R0, nottaken
PUTS ; else print "Branch Not Taken!"
BR END
BRANCH
LEA R0, taken
PUTS ; print "Branch Taken!"
END HALT
x .fill 1
y .fill 1
taken .stringz "Branch Taken!"
nottaken .stringz "Branch Not Taken!"
.end