What is the value in R5 after the following instructions are

What is the value in R5 after the following instructions are executed?

MOV.w   #0xF008, R5 ;R5 =

RRA.w R5 ;R5 =

RRC.w R5 ;R5 =   

SWPB.w R5 ;R5 =   

SXT R5 ;R5 =

Solution

MOV #0xF008,R5 ; R5<-F008    i,e R5= 1111 0000 0000 1000 carry (C)= x(no change)

R5= 0xF008

RRA.w R5 ; it shifts each bit of R5 towards right by one bit, MSB is unchanged, LSB is stored in carry bit

R5= 1111 1000 0000 0100 C=0

so R5= 0xF806

RRC.w R5 ; Carry bit is stored in MSB, the MSB->..LSB then LSB->C R5= 0111 1100 0000 0010 C= 0

So R5= 0x7C02

SWPB.w R5 ; it swaps MSB 8 bits with LSB 8 bits i,e R5=   0000 0010 0111 1100

So R5= 0x027C

SXT R5 ; It stores 7th bit of R5(i,e 0) into bit(8-15). R5= 0000 0000 0111 1100

So R5= 0x 007C

What is the value in R5 after the following instructions are executed? MOV.w #0xF008, R5 ;R5 = RRA.w R5 ;R5 = RRC.w R5 ;R5 = SWPB.w R5 ;R5 = SXT R5 ;R5 =Solutio

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site