First page Back Continue Last page Overview Text


C language code for a while loop:
//charPtr is a pointer that points to a NULL terminated string
//SendChar(char*) is a function that sends a character out an RS-232 port
This code sends characters in a string to a routine until a zero is detected in the character string. In this example the subroutine SendChar could output the characters to a serial port. The instruction jsr is a subroutine call and instruction psha puts the value in accumulator A onto the stack so that the subroutine can read it from the stack. Again in this example, note that a conditional test is completed at the beginning and at the end of the loop, there is an unconditional branch back to the start of the loop.

Instruction “ldaa 1,x+” means that the content of the memory location addressed by the content of register X plus 1 (indexed mode) is added to accumulator A. “+” means that the content of register X is incremented by 1.