First page Back Continue Last page Overview Text
C language code for a for loop:
//charPtr is a pointer that points to character string
//SendChar(char*) is a function that sends a character out an RS-232 port
//numChars is the number of characters to send
for(count=0; count<numChars; ++count)
In this program the counter (contained in accumulator B) is initialized at the beginning of the loop. This count is then compared to the number of characters to be sent (numChars) and if the requested number of characters has been sent, the program branches out of the loop. The counter is incremented before going back to the beginning and retesting the end condition. When the value in accumulator B is equal to or greater than numChars, the carry flag will be cleared after the comparison.