so I am creating a thing in the LMC where I count from 5 to 17 and display the odd numbers. I've got the code done however when I try to branch at zero when the code hits 17 it won't work and it will keep outputting past 17. The way I'm trying to do this is by subtracting 17 before every iteration of the loop and eventually when the counting variable I'm using hit's 17, 17 will be subtracted and it will branch at 0, halting the program. Can anybody tell me why this isn't working, maybe its the order in which I'm doing it?
lda third
print out
sub first
brz done
lda third
add second
sto third
br print
done hlt
first dat 0x17
second dat 0x02
third dat 0x05