title: How to rotate a matrix by 90 degrees in avr?
body: <p>I am trying to rotate the displaying letter by 90 degrees in both clockwise and anticlockwise direction. But when I'm executing the nested for loop, it gives an error like this.</p>
  
  <p>ALPHA is a 2d array which stores the hardcoded patterns of the letters A-Z. This program displays a static letter so far, if i comment out the nested for loop.</p>
  
  <pre><code>led.c: In function ‘main’:
  led.c:70:21: warning: iteration 1u invokes undefined behavior [- 
  Waggressive-loop-optimizations]
   ALPHA_NEW[k][j] = ALPHA[i][k];
                   ^
  led.c:68:4: note: containing loop
  for(int k = 0; k&lt;8; k++) 
  ^
  </code></pre>
  
  <p>is it not possible to assign values in avr like this?</p>
  
  <pre><code>#include &lt;avr/io.h&gt;
  
  //header to enable data flow control over pins
  
              #define F_CPU 1000000      
  
  //telling controller crystal frequency attached
  
              #include &lt;util/delay.h&gt;
  
  //header to enable delay function in program
  
  int main(void)
  {
  
        DDRD = 0xFF;//PORTD is set as output
        DDRA = 0xFF;
       //starts from msb..lsb
  
  //int ALPHA[1][8] = {0b00010000,0b00010000,0b00010000,0b00010000,0b00010000,0b00010000,0b00010000,0b00010000};
  int ALPHA[1][8] = {0b00111100,0b01000010,0b11000011,0b11111111,0b11000011,0b11000011, 0b11000011, 0b11000011};
      char NAME[] = {0};
      uint8_t l =0;
      char PORT[8] = {1,2,4,8,16,32,64,128};//pin values of PORTD
  
       int fl = 1; 
  
  int ALPHA_NEW[1][8] = {0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000};                      
  while(1)
  {
      //fl = 1 means rotate by 90 degree clockwise
      if(fl == 1) {
      for(int i = 0; i&lt; 8; i++)
      {
          for(int j = 8; j&gt;0; j--)
          {
              for(int k = 0; k&lt;8; k++) 
              {
                  ALPHA_NEW[k][j] = ALPHA[i][k];
              }
          }
          //ALPHA[0][i] = 0b00000000; 
  
      }
  //ALPHA[0][4] = 0b11111111;
  
          }
      for (int m=0;m&lt;sizeof NAME;m++)
      {
          l = NAME[m];
  
      for (int n=0;n&lt;800;n++)//execute 200 times for the eye to catch
  
       {
              for (int j=0;j&lt;4;j++)
  
                              {
                                   PORTD = PORT[j];// ROW
                                   PORTA = ~ALPHA[l][j];
                      _delay_ms(1);
                  }
  
                    // PORTD=0x00;//clear screen after show
  
                     for (int k=0;k&lt;4;k++)
  
                           {
                  PORTD = PORT[k+4];// ROW
                  PORTA = ~ALPHA[l][k+4];
                   _delay_ms(1);
  
                           }
  
  
  
          }
          PORTD=0x00;//clear screen after show.
             // _delay_ms(500);
  
  
      }
          //_delay_ms(500);
  
        }
  
  }
  </code></pre>