Simple assembly routine not working

Hey guys I'm trying to figure out why this assembler routine isn't working. I'm using an atmega16U2 chip connected to my USB port. The routine is just the assembly equivalent of
"counthigh++;"

void loop() {

  while (1) {
        delay(2000);
        Serial.write("\nx = ");
        Serial.write((counthigh/10) + 48);
        Serial.write((counthigh%10) + 48);

        asm volatile (
          "inc %0 \n\t"                
          : "=r" (counthigh)
          : 
          :
        );
  }
}

The output on the serial monitor is:
x=00
x=02
x=02
x=02
x=02
...

What happens when you try this?

: "+r" (counthigh)
1 Like

Well I'll find out.....YES that was it, much obliged :slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.