The following code generation has a problem handling
the external variable "command":
1) I dont see the global variable "command" has been put into r16
2) The while loop never loads r16 with the global before the test.
What is the proper way to tell the compiler what to do here?
------------------------------------------- C source
extern unsigned char command;
char *get_command(void)
{
int i = 0;
while(1)
{
command = NULL;
while(command == NULL);
// wait for command in uart getchar
if (command == CR)
85: command = NULL;
+0000096E: 9210150E STS 0x150E,R1 Store direct to data space
+00000970: E000 LDI R16,0x00 Load immediate
86: while(command == NULL);
+00000971: 2300 TST R16 Test for Zero or Minus
+00000972: F3F1 BREQ PC-0x01 Branch if equal
88: if (command == CR)
+00000973: 300D CPI R16,0x0D Compare with immediate