Search code examples
cassemblynios

Manipulating the Control register


can any one help me with how this code can affect the value in register ctl0 (disregarding the reserved bits). here is the code

rdctl r6,ctl0
andi r6, r6, 0x0006
wrctl ctl0, r6

Solution

  • Equivalent C pseudocode would be:

    r6 = ctl0;         // rdctl r6, ctl0
    r6 = r6 & 0x0006;  // andi r6, r6, 0x0006
    ctl0 = r6;         // wrctl ctl0, r6
    

    So, in other words,

    ctl0 = ctl0 & 0x0006;