Assembly Assume TEMP = 0x0F and W= 0xAA prior to the execution of each of the fo
ID: 3729421 • Letter: A
Question
Assembly
Assume TEMP = 0x0F and W= 0xAA prior to the execution of each of the following instructions. What will be content of TEMPE and W after execution of each of the following programs?
INCF TEMP,1 TEMP= W=
BSF TEMP, 4 ;TEMP= W=
BCF TEMP, 2 ;TEMP= W=
DECF TEMP,1 ;TEMP= W=
ANDWF TEMP,1 ;TEMP= W=
IORWF TEMP, 0 ;TEMP= W=
XORWF TEMP, 1 ;TEMP= W=
Explanation / Answer
TEMP = 0x0F and W= 0xAA before execution of each of instruction.
1. INCF TEMP,1
General format of this instruction is INCF f,d
If d = 1 then f = f+1
else
W = f +1
In the given instruction d =1 therefore TEMP = TEMP +1 = 0x0F + 1 = 0x10
TEMP = 0x10 W = 0xAA
2. BSF TEMP, 4
Set bit 4 of TEMP
TEMP = 0x0F = (0000 1111)2
After executing instruction TEMP = (0001 1111) = 0x1F
TEMP = 0x1F W = 0xAA
3. BCF TEMP, 2
Clear bit 2 of TEMP
TEMP = 0x0F = (0000 1111)2
After executing instruction TEMP = (0000 1011) = 0x0B
TEMP = 0x0B W = 0xAA
4. DECF TEMP,1
General format of this instruction is DECF f,d
If d = 1 then f = f-1
else
W = f -1
In the given instruction d =1 therefore TEMP = TEMP -1 = 0x0F - 1 = 0x0E
TEMP = 0x0E W = 0xAA
5. ANDWF TEMP,1
General format of this instruction is ANDWF f,d
If d = 1 then f = f AND W
else
W = f AND W
In the given instruction d =1 therefore TEMP = TEMP AND W
TEMP = 0x0F AND 0xAA
= (0000 1111) AND (1010 1010)
= 0000 1010
Therefore,
TEMP = 0x0A W =0xAA
5. IORWF TEMP, 0
Here d =0
Therefore , W = W OR TEMP
= (0xAA ) OR (0x0F)
=(1010 1010) OR (0000 1111)
= 1010 1111 = 0xAF
Therefore TEMP =0x0F and W = 0xAF
6. XORWF TEMP, 1
Here d = 1
Therefore, TEMP = TEMP XOR W
= (0x0F) XOR (0xAA)
= (0000 1111) AND (1010 1010)
= 1010 0101 = 0xA5
Therefore, TEMP = 0xA5 W = 0xAA
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.