I have problems understanding what does this instruction do MOV number,#(4+3)SHL(4)SHR(4) googling gave me this "operand1 SHL operand2" which is different than the instruction i wrote above . Can somebody please explain it to me I also have problems understanding what does this code do using 1 MOV R0,#1 MOV AR0,#2 /* what do we use AR0? since I have always used the instruction mov rn,#immediate and this one is new to me */ SETB RS0
MOV R0,#3

  • \$\begingroup\$ AR0 is declared anywhere. Search on entire code or binded libraries and you will find its value, which means what compiler see. \$\endgroup\$ Oct 30 '17 at 6:58
  • 1
    \$\begingroup\$ I don't see the instruction you mention in your description anywhere in your code. \$\endgroup\$ Oct 30 '17 at 10:47
  • \$\begingroup\$ this is just a part of the code and the mentioned instruction MOV number,#(4+3)SHL(4)SHR(4) also in the code \$\endgroup\$
    – layla
    Nov 1 '17 at 18:32

The registers in the 8051 are mapped into the first addresses of the internal RAM like so:

0x00 -> 0x07 ---> Registers R0 to R7 of register set 0

0x08 -> 0x0F ---> Registers R0 to R7 of register set 1

0x10 -> 0x17 ---> Registers R0 to R7 of register set 2

0x18 -> 0x1F ---> Registers R0 to R7 of register set 3

Since many of the 8051 instructions can directly address the internal RAM it is possible to compose a MOV instruction that can move data to one of the registers by using its corresponding internal RAM address.

Some compilers or assembly language tool sets will create intrinsic symbols that specify internal RAM addresses. AR0 is an example of this. It is common that AR0 is defined to be 0x00 so that it references the memory location where the R0 register is stored in register set 0. In your example the "USING 1" statement says to use register set 1 so when the subsequent instruction "MOV R0,#1" is encountered it ends up storing the value of 1 into internal memory location 8 whilst the next instruction "MOV AR0,#2" is placing the value of 2 to the address that AR0 represents (most likely 0x00).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.