MICROPROCESSORS AND MICROCONTROLLERS (BECE204L)
SAMPLE QUESTIONS FOR CAT1
1. For 8051 Microcontroller, interpret the contents of various locations and the position of
stack pointer after executing each and every instruction of the following code.
Ans 29H+01H = 2AH (Hex)
Line Program Contents
Number
1. MOV 00H,#29H 00H : 29H ; SP : 07H
2. MOV 10 H,#30H 10H : 30H ; SP : 07H
3. MOV 18H,#31H 18H : 31H ; SP : 07H
4. MOV SP.#29H SP : 29H
5. PUSH 00H 00H : 29H ; SP : 2AH
6. PUSH 18H 18H : 31H ; SP : 2BH
7. PUSH 30H 30H : 00H ; SP : 2CH
8. POP 31H 31H : 00H ; SP : 2BH
9. POP 18H 18H : 31H ; SP : 2AH
10. PUSH 18H 18H : 31H ; SP : 2BH
11. POP 19H 19H : 31H ; SP : 2AH
12. END
2. Examine the size of delay in the following program, if the crystal frequency of 8051
microcontroller is 11.0592 MHz.
Label Opcode Machine Cycle
MOVR0,#0A0h 1
L3: MOV R1,#40h 1
L2: MOV R3,#20h 1
L1: DJNZ R3, L1 2
DJNZ R1,L2 2
DJNZ R0,L3 2
RET 2
3. For 8051 Microcontroller, identify the error if any in the following instructions and discuss
the error in detail.
i. MOV R1,R2 (error: invalid resister, data can not transfer directly from one
register to another register)
ii. ADD #40H,A (Error: Destination should be address)
iii. MOV A, @R2 (Error: only R0 or R1 can be used for indirect addressing mode)
iv. XOR R0,23H (Error: syntax error, XRA A, R0)
v. MOV C,A (Error: C is sngle bit and A is 8 bit, content of A can not be
transferred to C)
4. Analyze the following code and specify the content of various registers and Program Status
Word (PSW) after the execution of each instruction.
ORG 00H
MOV A,#00H A =? 00H PSW =? 00H
MOV R5,A R5=? 00H
MOV R0,#0F4H R0=? F4H
ADD A,#89H A=? 89H PSW=? 01H
JNC N_1
INC R5
N_1 : ADD A,#0A5H A=? 2EH PSW =? 84H
JNC N_2
INC R5
N_2 : ADD A,#0E2H
JNC OVER
INC R5
OVE : MOV @R0,A
R
END
5. The initial values of the memory location (06h-09h) are given below in the Table
Memory Initial Final value
location value
09h 88(h) ?
08h 10(h) ?
07h AD(h) ?
06h 67(h) ?
Identify the final values in these locations after execution of the following program.
ORG 00H
PUSH 06H
MOV SP, #09H
POP 06H
END
Ans
6. Identify the addressing mode for
a) POP 0 b) MOV A, #255 c) MUL AB d) MOV 40H, #40H e) MOV @R1, A
a) POP 0
Addressing Mode: Direct Addressing
o The value at the direct address 00H is popped from the stack into the specified address.
Direct addressing refers to accessing data stored at a fixed memory location.
b) MOV A, #255
Addressing Mode: Immediate Addressing
o The value 255 (immediate data) is moved directly into the accumulator (A). Immediate
addressing refers to the data being provided as part of the instruction.
c) MUL AB
Addressing Mode: Register Addressing
o The instruction operates on the registers A and B without specifying them explicitly in an
addressing mode. The MUL instruction multiplies the content of the accumulator (A) and
register B.
d) MOV 40H, #40H
Addressing Mode: Direct Addressing (for 40H) and Immediate Addressing (for
#40H)
The value 40H is moved to the memory location 40H.
e) MOV @R1, A
Addressing Mode: Indirect Addressing
o The content of the accumulator (A) is moved to the memory location pointed to by the
content of register R1. Indirect addressing uses a register to hold the memory address.
7. Sketch the content of the stack after the execution of the following code:
PC Opcode Mnemonic Operand
000B 120300 LCALL DELAY
000E 80F0 SJMP BACK
0010 ; ------------ this is the delay subroutine
0300 ORG 300H
0300 DELAY:
0300 7DFF MOV R5, #0FFH
0302 DDFE AGAIN: DJNZ R5, AGAIN
0304 22 RET
Ans.
Before executing CALL instruction SP = 07H
After executing CALL instruction SP = 09H
0BH
0AH
09H 00H
08H 0EH
8. Assume A = 79H, R0 = 94H. what is the content in A after the execution of the following
instructions.
i. MOV A, R0 Ans. 94H
ii. SWAP A Ans. 97H
iii. XCHD A, R0 Ans. A= 94H, R0 = 79H
iv. ADD A, R0 Ans. 0DH
9. Describe binary addition using 8051 Microcontroller for the data 0FH and F0H and show
the status of PSW.
Ans.
A = FFH
PSW = 00H
10. Assume string of data is stored in code space starting at address 200H as shown below
MYDATA: “VIT UNIVERSITY”. Write an 8051 ALP to transfer this string of data in
reverse order i.e. “YTISREVINU TIV” to RAM locations inside the CPU starting at 40H.
Ans.
ORG 0000H
MOV DPTR, #020DH
MOV R1, #14
MOV R0, #40H
LOOP: CLR A
MOVC A, @A+DPTR
MOV @R0, A
DEC DPL
INC R0
DJNZ R1, LOOP
HERE: SJMP HERE
ORG 0200H
DB "VIT UNIVERSITY"
END