I need to be able to count to around 2000 without rolling over so 2 bytes would be plenty. I tried the code you posted.. but it still rolled over at 255. hmmm....
I need to be able to count to around 2000 without rolling over so 2 bytes would be plenty. I tried the code you posted.. but it still rolled over at 255. hmmm....
It still rolls at 255 ? Did yoiu declare the destination variable as a word or a byte ?
Ever count of 1 of the lower byte equates to 1 in the destination variable, and every count of 1 in the high byte equates to 256 in the destination variable.
2000, in this scheme, consists of highbyte = 7, low byte = 208
As you can see, you need to multiply whatever is in the highbyte by 256. In this case 256*7 = 1792. Then add the lowbyte directly, and 1792 + 208 = 2000
Bookmarks