All Exams Test series for 1 year @ ₹349 only
Comprehension

The following 8051 assembly program is given. Answer the questions based on it.

Line No.  Mnemonics
1MOV SP, #4F H
2SET B PSW.3
3MOV R0, #25H
4MOV R1, #0AH
5MOV R2, #06H
6PUSH 8
7PUSH 9
8PUSH 0AH
 .
 .
 .
VV
20POP 8


Question 1
The correct answer is

50H

The rule for the 8051 stack. The stack grows upward in internal RAM, and on every PUSH the sequence is:

1. increment SP by one, then 2. write the data byte at the new address in SP.

So SP always points to the byte most recently stored — the current top of stack — and the next free location is SP + 1.

Apply it to this program. Line 1 set SP = 4FH. The first push in the program is line 6, \(\texttt{PUSH 8}\). When it executes:

\(SP \leftarrow 4FH + 1 = 50H\)

and the data byte is then written to address 50H.

Therefore the first data byte is stored at 50H, not at 4FH — location 4FH is never written to at all; it is merely the starting marker below the stack area.

Why pre-increment matters. Contrast this with a POP, which reverses the order: read the byte at SP first, then decrement SP. Together the two rules keep SP consistently pointing at the last valid entry, so a stack that has been pushed and popped equally often returns SP to its original value. Following the same rule, the next push (line 7) will use 51H and the one after that 52H, which is how the later questions in this set are answered.

Checking the distractors. 4FH ignores the pre-increment; 51H and 52H correspond to the second and third pushes.

Hence, the first data byte is stored at memory location 50H.

Was this answer helpful?

Question 2
The correct answer is

25 H

This question needs three separate facts to be combined: which register bank is active, what that makes the direct address of R0, and how PUSH works.

Step 1 — which register bank? The instruction \(\texttt{SETB PSW.3}\) sets RS0 = 1 while RS1 (PSW.4) remains 0. The bank-select bits therefore read RS1 RS0 = 01, which selects register bank 1.

RS1 RS0BankAddress range 
0 0Bank 000H – 07H
0 1Bank 108H – 0FH
1 0Bank 210H – 17H
1 1Bank 318H – 1FH

So in bank 1: R0 = address 08H, R1 = 09H, R2 = 0AH.

Step 2 — what is at address 08H? Line 3, \(\texttt{MOV R0, \#25H}\), loads the immediate value 25H into R0 — which, with bank 1 active, physically means RAM location 08H now holds 25H.

Step 3 — what does PUSH 8 push? PUSH takes a direct address as its operand, not a register name. \(\texttt{PUSH 8}\) therefore pushes the byte stored at address 08H, which is 25H. (This is why the bank matters: had bank 0 been active, R0 would be at 00H and address 08H would be R0 of bank 1 instead.)

Step 4 — where does it land? SP was 4FH, so it is pre-incremented to 50H and the byte is written there:

\(50H \leftarrow 25H\)

Why the distractors are wrong. 0AH is the value in R1 (address 09H), pushed later by line 7; 06H is in R2 (address 0AH); 4FH is the old SP value, which is never itself pushed.

Hence, memory location 50H holds 25H.

Was this answer helpful?

Question 3
The correct answer is

51H, 0AH

 State of the register bank. With \(\texttt{SETB PSW.3}\) having selected bank 1, the registers map to internal RAM as R0 → 08H, R1 → 09H, R2 → 0AH, and lines 3–5 have loaded them:

RegisterDirect addressContents
R008H25H
R109H0AH
R20AH06H

Trace the pushes.

Line 6, \(\texttt{PUSH 8}\): SP goes 4FH → 50H, and the byte at address 08H (25H) is written to 50H.

Line 7, \(\texttt{PUSH 9}\): SP is pre-incremented 50H → 51H, and the byte at direct address 09H is written there. Address 09H holds 0AH (put there by \(\texttt{MOV R1, \#0AH}\)), so

\(51H \leftarrow 0AH, \qquad SP = 51H\)

Both parts of the answer therefore read 51H and 0AH.

The trap in this question. The value 0AH appears twice in the program in two completely different roles — as the data loaded into R1, and as the address of R2 in bank 1. Reading \(\texttt{PUSH 9}\) you must remember the operand 9 is an address (09H = R1), while the byte it contains, 0AH, is data. The distractors exploit exactly this: option 1 offers 25H (the previous push), option 2 gives an SP of 52H (one push too many), option 3 gives the previous SP with the new data.

Stack picture after line 7 (SP marks the top): 50H = 25H, 51H = 0AH ← SP.

Hence, after line 7 the SP register holds 51H and stack location 51H contains 0AH.

Was this answer helpful?

Question 4
The correct answer is

4F H

The instruction on line 1. \(\texttt{MOV SP, \#4FH}\) — the "#" marks 4FH as an immediate constant, and SP is the Stack Pointer, a special-function register at address 81H. The instruction therefore writes the byte 4FH straight into SP.

What SP holds afterwards. No PUSH, POP, CALL or RET has executed yet, and only those operations change SP. So immediately after line 1,

\(SP = 4FH\)

Why the program does this at all. On reset the 8051 initialises SP to 07H, which means the very first PUSH writes to 08H — the start of register bank 1. Any program that uses more than the default bank 0 must therefore move the stack out of the way, and 4FH puts it in the general-purpose scratchpad area (30H–7FH), safely above the register banks (00H–1FH) and the bit-addressable region (20H–2FH).

Where it goes next. Because the 8051 stack grows upward and SP is pre-incremented on a push, the first byte pushed will land at 50H, not at 4FH — SP always points at the last byte written, i.e. the current top of stack. That distinction is what the following questions in this set test. With SP at 4FH, the available stack space runs up to 7FH, i.e. 48 bytes.

Ruling out the distractors. 5FH, 3FH and 6FH would each require a different immediate operand; the instruction as written moves exactly 4FH.

Hence, after line 1 the SP register contains 4FH.

Was this answer helpful?

Question 5
The correct answer is

06H

How the 8051 stack unwinds. The stack is LIFO — last in, first out. A POP reverses a PUSH: it reads the byte at the address currently in SP, writes it to the destination, and then decrements SP.

State of the stack before the POP. With bank 1 selected (R0 → 08H, R1 → 09H, R2 → 0AH holding 25H, 0AH and 06H respectively), the three pushes have filled the stack as:

AddressContentsPushed by
50H25HPUSH 8 (byte at 08H)
51H0AHPUSH 9 (byte at 09H)
52H06HPUSH 0AH (byte at 0AH) ← top, SP = 52H

Execute POP 8. The destination operand 8 is the direct address 08H, which with bank 1 active is register R0. The instruction takes the byte at the top of the stack — 06H at address 52H — writes it into 08H, and decrements SP to 51H. Therefore

\(R0 = 06H\)

The point being tested. R0 originally held 25H, and 25H is still sitting at the bottom of this group of pushes (50H). Because the stack is LIFO, the first POP returns the last value pushed, not the value that R0 started with. Restoring registers correctly therefore requires the POPs to be written in the exact reverse order of the PUSHes — pop 0AH, then 9, then 8 — otherwise the register contents are swapped, which is a classic bug in interrupt service routines.

Distractors. 0AH would be the result of the second pop, 25H of the third, and 4FH is the initial SP value, which is never a data byte.

Hence, after line 20 (POP 8) register R0 contains 06H.

Was this answer helpful?

Similar Questions

  1. A microprocessor is a semiconductor chip fabricated with entire central processing unit (CPU) on it. It is a programmable device that accepts binary data from an input device, processes the data according to the instructions stored in the memory and provides results as output. Basically microprocessor performs two functions - (a) Fetches an instruction from the memory and (b) Performs the operation specified by the instruction. There are special inputs to the microprocessor called interrupts. External devices use these interrupts to get the microprocessor attention. A micro computer can be built by using 8085 microprocessor along with many other chips such as 8155, 8255, 8279, 8253, 8257, 8259, 8251 etc. 8085 microprocessor is 8-bit microprocessor which has 8-bit data registers where as 8086 is a 16-bit microprocessor.

  2.  

    $D_7$$D_6$$D_5$$D_4$$D_3$$D_2$$D_1$$D_0$

    In 8255 programmable peripheral interface device, if the port A and port B are to be set in a hand shake mode along with port C, what are the bits in the 8 bit control word  to be set as 0 1 0.

  3. The number system for the machine code of the microprocessor 8085 is

  4. Which of the options in a multipurpose instruction used to implement the interrupt of 8085 and serial data input ?

  5. Both 8155 and 8255 programmable peripheral interface ICs have the following common features :

    (i) Programmable I/Os
    (ii) Either port A or Port B can be set as either input or output ports.
    (iii) One 14-bit down counter
    (iv) AD0 – AD7 are multiplexed address/datalines.

  6. Each instruction in an assembly program has the following fields :

    (i) Lable field
    (ii) Operand field
    (iii) Comment field
    (iv) Mnemonic field

    Please write the proper sequence of fields :

  7. The mnemonic of 8085 processor indicate :

    List – I  List – II  
    a. RLCi. Rotate Accumulator Right through carry
    b. RRCii. Rotate Accumulator Left through carry
    c. RARiii. Rotate Accumulator Left
    d. RALiv. Rotate Accumulator Right

    Codes :

  8. Match the following :

    List – I (Pin terminals)List – II (Applications)  
    a. SID, SODi. Wait state
    b. READYii. Serial data transfer
    c. TRAPiii. Address Latch Control
    d. ALEiv. Interrupt

    Codes :

  9. Assertion (A) : In serial communication system, when the transmission of data goes in both ways, it is called full-duplex system. Now if two micro processors are connected in full duplex mode, the amount of data transmitted will be double to the amount of data in half-duplex mode connection.

    Reason (R) : When the transmission of data goes in one way, it is called half-duplex system and when the data moves in both ways, it is called full duplex system.

  10. The assembler directive used to give name to some value or symbol for 8086 ASM-86 is


Important Questions from Microprocessors

  1. An 8086 address bus is a/an _____ -bit bus

  2. Program counter for any counter:

  3. In the pin out configuration of the 8085 microprocessor, the sequential input data is represented by

  4. Which of the following functions is not performed by a microprocessor?

  5. Match the columns.

    Pin

    Description

    a. D 0-D 7

    1. Reset Input

    b. RESET

    2. Data Lines

    c. A 0,A 1

    3. Internal Address

Need Expert Advice?
Test Series
UGC NET img
Teaching
UGC NET (Paper 1) 2026 Mock Test Series
476 Tests 1 Tests Free
4.3(72)
English
More Questions from UGC NET

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App