But inside my while loop the iterator seems to get reset every iteration of the loop. Here's my code.
Code: Select all
extern void main() {
uint8_t i = 0; // declare i
void setchar(uint16_t id, char letter) {
volatile char *addr = (char*)0xB8000 + id * 2;
*addr = letter;
return;
}
void print(char string[]) {
i = 0; // set i to 0
while (string[i] != '\0') {
// i is 0 after EVERY iteration (not just first time)
setchar(i, string[i]);
i = i + 1;
// i does get set to 1 here but is reset to 0 on next iteration
}
return;
}
print("test");
return;
}
And my setchar function works just fine.
If set all the characters manually...
Code: Select all
setchar(0, 't');
setchar(1, 'e');
setchar(2, 's');
setchar(3, 't');
I don't know why this is doing that. It may just be a super simple beginner mistake, but I don't know. Any help would be appreciated, Thanks.