test a variable
if the result is not what you want branch to out
body of the then clause
out: instructions following if
test a variable
if the result is not what you want branch to else
body of the then clause
branch to out
else: body of the else clause
out: instructions following if
initialize the lcv
top: test a condition
branch out of the loop if the condition is met
do some loop body things
change the lcv
branch back to the test condition.
done: instructions following the loop.
initialize the lcv
top: do the body stuff
test the lcv
branch on result of test to top of body
instructions following loop
i = 10
while (i > 0) {
cout << i
i = i -1
}
0 loadi 11 0x5B 1 top sub one 0x36 2 jz out 0x85 3 output 0xE0 4 j top 0x61 5 out halt 0xF0 6 one 1 0x01
0 load a 0x18 1 sub b 0x39 2 jc carry 0x75 3 loadi 1 0x51 4 j done 0x66 5 carry: loadi c 0x1b 6 done out 0xe0 7 halt 0xf0 8 a 3 0x03 9 b 4 0x04 a one 1 0x01 b c c 0x0c