EmbeddedRelated.com
Forums

8051 - moving value from one register to another

Started by Josip February 23, 2009
Just a quick question regarding 8051 assembly programming:

I need to transfer a value from register R5 to R0, so I can use R5 for
something else. I tried MOV R0, R5 but it fails.
I know this is begginer's question, but I guess it wouldn't take to much
time for someone experienced to answer this.

Thanks
Josip




Solved it myself. I transfered the value over accomulator.
MOV A, R5
MOV R0, A
I was afraid I would have to use RAM to make the transfer, but this solution 
suits me fine.
Enough talking to myself...
Bye

"Josip" <sorry.no@can.do> wrote in message 
news:gntp5j$qqg$1@ss408.t-com.hr...
> Just a quick question regarding 8051 assembly programming: > > I need to transfer a value from register R5 to R0, so I can use R5 for > something else. I tried MOV R0, R5 but it fails. > I know this is begginer's question, but I guess it wouldn't take to much > time for someone experienced to answer this. > > Thanks > Josip
Josip schrieb:

> Solved it myself. I transfered the value over accomulator. > MOV A, R5 > MOV R0, A
If you want to preserve the content of the accumulator, you might as well use "MOV R0,5" - the 5 will be used as memory address 5, which in fact is R5 in register bank 0. This method is fine as long as you know which register bank you are using. Some assemblers already have predefined constants for these memory addresses (like "AR5" in mine, standing for "absolutely addressed R5"). Tilmann