Microprocessor Quesion Solve-2019

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

Microprocessor Question Solve-2019

1.
(a) What are the differences between Microprocessor and Microcontroller?
Ans.

(b) Why INTEL named the 8086 Microprocessor as '8086'? Briefly explain the
internal 4 pin diagram architecture of 8086 CPU (Draw the block diagram also).
Ans.
8086 Microprocessor is an advanced version of 8085 Microprocessor, designed by
Intel in 1976. The number 8086 denotes the IC number of this microprocessor.
That is why, INTEL named the 8086 Microprocessor as '8086'.
(c) Why we need to use latch for 8086 microprocessors?
Ans.
The latch is one of the most important circuits in the 8086, since the latches keep
track of what the processor is doing. While latches can be made in many ways,2
the 8086 uses a compact circuit called the dynamic latch.
That is why, we need to use latch for 8086 microprocessors.

(d) Define system bus. Address bus is unidirectional and data bus bidirectional,
what do think about it?
Ans.
System bus:
A system bus is a single computer bus that connects the major components of a
computer system, combining the functions of a data bus to carry information, an
address bus to determine where it should be sent or read from, and a control bus
to determine its operation.
Address bus is unidirectional and data bus bidirectional:
Address bus is unidirectional because it only carries memory addresses from the
processor to memory and other peripherals. Data bus is bidirectional because it
facilitates the transfer of data between the processor and memory or peripherals
in both directions.

3.
(a) Describe Addressing mode of microprocessor with proper example.
Ans.

The addressing modes in 8085 microprocessors are instructions used to transfer


data and perform operations on them.

An 8085 microprocessor uses five addressing modes: Immediate addressing


mode, Register addressing mode, Register indirect addressing mode, Direct
addressing mode, and Implicit addressing mode.

Immediate addressing mode

In this addressing mode, the data on which the operation is to be performed is


mentioned in the instruction. Instead of specifying an address, the instruction
specifies an operand along with the operation that is to be performed. The
instruction is 2 bytes when there is 8-bit data and 4 bytes when there is 16-bit
data. Examples of instructions that use immediate addressing mode are:

 MVI B 05
 JMP address
 LXI H 3000

Register addressing mode

In this addressing mode, the instruction mentions a register which stores some
data. The operation specified by the instruction is performed in the register
specified by it. The instruction can also specify two registers. The size of the
instructions in register addressing mode is 1 byte. The instruction’s opcode
includes both the register and the operation to be performed. Examples of
instructions that use register addressing mode are:
 ADD B
 INR B
 MOVE B, D
 PCHL

Direct addressing mode

In this addressing mode, the instruction specifies some address which stores the
data. This memory location is mentioned in the instruction as an operand. The
size of an instruction in the direct addressing mode is 3 bytes. However,
input/output instructions in direct addressing mode are 2 bytes. Examples of
instructions that use direct addressing mode are:

 IN 35
 LHLD address
 LDA 2050
 STA 2050

Register Indirect addressing mode

In this addressing mode, the data on which the operation is to be performed is


stored in some memory location. This memory location is specified in a register
pair. The instruction then specifies this register pair. Examples of instructions that
use register indirect addressing mode are:

 LDAX
 LXIH 9500
 MOV A, M

Implied/Implicit addressing mode

In this addressing mode, the operand is described implicitly in the definition of


the instruction. The operand is specified with the opcode of the instruction. The
size of an implied addressing mode instruction is 1 byte. The instructions
generally operate on data stored in the accumulator. Examples of instructions
that use implied addressing mode are as follows:

 RRC
 RLC
 CMA

(b) If the last two instructions are not written in any assembly language
program, what will happen?
MOV AH, 4CH
INT 21H
MAIN ENDP
Ans.
if the preceding instructions are missing or incorrect, it's challenging to determine
exactly what will happen without more context. The behavior of the program will
depend on the values in registers and memory at the time of execution and how
the program handles them.
(c) Write an assembly language program to convert the following input into
desired output.
Input: ABC Output: A B C
Ans.

.MODEL SMALL

.STACK 100H

.DATA

inputString DB "ABC$"

outputString DB 20 DUP('$') ; Buffer to store the output string


.CODE

MAIN PROC

MOV AX, @DATA

MOV DS, AX

; Initialize variables

MOV SI, 0 ; Source index for inputString

MOV DI, 0 ; Destination index for outputString

NextChar:

MOV AL, inputString[SI]

CMP AL, '$' ; Check for the end of the input string

JE EndProgram

MOV outputString[DI], AL

INC DI

MOV AL, ' ' ; Insert a space after each character

MOV outputString[DI], AL

INC DI
INC SI

JMP NextChar

EndProgram:

MOV outputString[DI], '$' ; Add null terminator to the output string

; Display the output string

MOV AH, 09H

LEA DX, outputString

INT 21H

MOV AH, 4CH ; Exit the program

INT 21H

MAIN ENDP

END MAIN
4.
(a) Briefly Explain the Logical Address, Base Segment Address and Physical
Address.
Ans.

- Logical address is contained in the 16-bit IP, BP, SP, BX, SI or DI. It is also known
as the offset address or the effective address.
- The base segment address is contained in one of the 16bit contents of the
segment registers CS, DS, ES, SS.

- The physical address or the real address is formed by combining the offset and
base segment addresses. This address is 20bit and is primarily used for the
accessing

of the memory.

(b) What is the position of the Stack Pointer After the Pop Instruction?
Ans.
After the "Pop" instruction is executed in a typical computer architecture, the
Stack Pointer will be incremented by the size of the data being popped from the
stack. This operation removes the topmost item from the stack, adjusting the
Stack Pointer to point to the next item in the stack.

5.
(a) Write a program to add a data byte located at offset 0500H in 2000H
segment to another data 2 byte available at 0600H in the same segment and
store the result at 0700H in the same segment.
Ans.
MOV AX, 2000H; initialize DS with value
MOVDS, AX; 2000H
MOV AX, [500H]; Get first data byte from 0500H offset
ADD AX, [600H]; Add this to the second byte from 0600H
MOV [700H],AX; store AX in 0700H HLT;
Stop

(b) Explain the use of SI and DI register during string operations.


Ans.

During string operations, the SI (Source Index) and DI (Destination Index) registers
are used to hold memory addresses for the source and destination strings,
respectively. These registers are crucial for data movement and manipulation in
memory.

 SI (Source Index): It holds the memory address of the source string from
which data is to be read during string operations like "movsb" (move byte
from source to destination) or "cmpsb" (compare byte from source with
destination). It is automatically incremented after each operation to point
to the next element in the source string.
 DI (Destination Index): It holds the memory address of the destination
string where data is to be written during operations like "movsb" or "stosb"
(store a byte into the destination). Similar to SI, DI is automatically
incremented after each operation to point to the next location in the
destination string.

By using SI and DI registers, string operations can efficiently transfer data


between memory locations and perform string comparisons or other
manipulations.

(c) What is the maximum memory addressable size by the 8086? Explain briefly
the string 3 addressing mode with the help of an example? What is the purpose
of index registers in 8086?
Ans.
The maximum memory addressable size by the 8086 is 1 MB.
Let's take a look at the different types of addressing modes, one at a time now.

1. Immediate

Figure 1. Immediate
2. Direct Addressing

Figure 2. Direct

3. Register Addressing

Figure 3. Register

The purpose of index registers:


The purpose of index registers in the 8086 microprocessor is to facilitate efficient
memory access and manipulation during data transfer and string operations.

(d) What do you mean by I/O mapped I/O and memory mapped I/O? Explain
with example.
Ans.
These two methods are called memory mapped IO and IO mapped IO.
Memory-mapped I/O:
Memory-mapped IO uses the same address space to address both memory and
I/O devices.
Example:
let us say, the chip select pin of an I/O port chip is activated when address =
FFF0H, IO/M* = 0, and RD* = 0.
IO mapped I/O:
IO mapped IO uses separate address spaces to address memory and IO devices.
Example:
let us say, the chip select pin of an I/O port chip is activated when 8-bit address =
F0H, IO/M* = 1, and RD* = 0.
6.
(a) Write an assembly language program to convert a binary number into
hexadecimal number.
Ans.

mov ecx,[ebp+8] ;Pointer to an ASCIIZ string of zero and one characters.

xor ebx,ebx

First:

rcl ebx,1

mov al,[ecx]

inc ecx

shr al,1

jnz First

mov ecx,LC1 ;Buffer to recieve 8 hexcharacters.

Again:

rol ebx,4

(b) Write all possible assembly language instructions for the following things:
i.Converting an ASCII digit to a number.
ii. Converting a lowercase letter to an uppercase letter.
iii.Clearing a register.
iv.Testing a register zero.
Ans.

i.Converting an ASCII digit to a number:


SUB AL, '0' ; Subtract the ASCII value of '0' from the AL register to convert to a
number.

ii. Converting a lowercase letter to an uppercase letter:

AND AL, 0xDF ; Using the AND operation with 0xDF (11011111 in binary) clears
the 6th bit (32 in decimal), converting a lowercase letter to uppercase.

iii. Clearing a register:

XOR AX, AX ; Using XOR operation with a register and itself (or another register)
sets all bits to zero, effectively clearing the register.

iv. Testing a register zero:

TEST AX, AX ; The TEST instruction performs a bitwise AND operation on a


register with itself. It sets the flags according to the result but does not modify the
register.

(c) Suppose that a stack segment is declared as follows:


.STACK 100h
i..What is the hex contents of SP when the program begins?
ii.What is the maximum hex number of words that the stack may contains?
Ans.

i. The hex contents of SP when the program begins would be 100h, which is the
initial value set for the stack segment.

ii. The maximum hex number of words that the stack may contain is 100h (256
words), as specified by the size of the stack segment.

7.
(a) Write an assembly language program for 8086 microprocessors to add 1 to
100.
Ans.

TITLE "TO PRINT THE SUM OF NATURAL NUMBERS FROM 1 TO 100"


.MODEL SMALL

.STACK

.DATA

VAL DB 1

.CODE

MAIN PROC

MOV AX,@DATA

MOV DS,AX

MOV BX,1

MOV CX,100

MOV AX,0

TOP:

ADD AX,BX

INC BX

LOOP TOP

XOR DX,DX

MOV BX,100

DIV BX
AAM

ADD AX,3030H

PUSH DX

MOV DH,AL

MOV DL,AH

MOV AH,02H

INT 21H

MOV DL,DH

MOV AH,02H

INT 21H

POP AX

AAM

ADD AX,3030H

PUSH DX
MOV DH,AL

MOV DL,AH

MOV AH,02H

INT 21H

MOV DL,DH

MOV AH,02H

INT 21H

MOV AH,4CH

INT 21H

MAIN ENDP

END MAIN

(b) Write some code to


i.Place the top of the stack into AX, without changing the stack contents.
ii.Place the word that is below the stack top into CX, without changing the stack
contents, you may use AX.
Ans.

Here's some 8086 assembly code to achieve the tasks:

i. Place the top of the stack into AX without changing the stack contents:

MOV AX, [SP]


ii. Place the word that is below the stack top into CX, using AX:

PUSH CX ; Save CX on the stack to preserve its value

POP AX ; Move the top of the stack (word below previous SP) into AX

MOV CX, AX ; Move the value in AX into CX

PUSH AX ; Restore the original value of AX on the stack

(c) Write down the differences between address and addressing mode with
suitable examples.
Ans.

Address: An address refers to a specific location in memory or a register where


data is stored or fetched from. It represents the location of data or an instruction
within the computer's memory or registers.

Example: In x86 assembly language, [BX] represents the memory address stored
in the BX register.

Addressing Mode: Addressing mode refers to the way in which the operand's
address is specified in an instruction. It defines how the processor calculates the
effective address of the operand.

Example: In x86 assembly language, "mov AX, [BX]" uses the "direct addressing
mode" where the operand is the value stored at the memory address pointed to
by the BX register.

8.
(a) Explain the execution of the following code with memory operation and
changing of values
in different register.
0100: E8 04 00
0103: B8 02 00
0106: C3
0107:
0107: BB 05 00
010A: C3
CALL m1 MOV RET ml
AX, 2
PROC
MOV
BX, 5
RET
Ans.

Let's go through the code step by step:

i.0100: E8 04 00 - CALL m1

This instruction is a relative call to the memory address "m1". It pushes the
current IP (Instruction Pointer) value (0103) onto the stack and jumps to the
address m1 (0107).

ii.0107: BB 05 00 - MOV BX, 5

This instruction moves the value 5 into the BX register.

iii.010A: C3 - RET

The RET instruction will pop the return address (0103) from the stack and transfer
control back to that address. So, the program returns to 0103.

iv.0103: B8 02 00 - MOV AX, 2

This instruction moves the value 2 into the AX register.

v.0106: C3 - RET

The RET instruction will pop the return address (0100) from the stack and transfer
control back to that address. So, the program returns to 0100.
At this point, the "m1" procedure has executed, and the AX register contains the
value 2, and the BX register contains the value 5.

Overall, the code sequence calls the "m1" procedure, which sets the BX register to
5 and returns, and then sets the AX register to 2 and returns. The final state of the
registers will be AX = 2 and BX = 5.

(b) Define hardware and software interrupt. Which pins of 8086 are responsible
for executing the 2 interrupt procedure?
Ans.
Hardware interrupt is an interrupt generated from an external device or
hardware.
Software interrupt is the interrupt that is generated by any internal system of the
computer.
Interrupt Flag (I) pins of 8086 are responsible for executing the 2 interrupt
procedure.
(c) Computer runs without any RAM is it true or false. Defend your answer with
suitable 3 examples.
Ans.

False. A computer cannot run without any RAM. Here are three examples to
support this:

 Booting: When a computer starts up, the BIOS (Basic Input Output System)
is loaded into RAM. Without RAM, the BIOS could not execute, and the
computer would not be able to go through the boot process.
 Operating System: The operating system is loaded into RAM during the
boot process. It manages hardware, software, and memory resources.
Without RAM, the computer would not have a place to load the OS, and
thus, it wouldn't be able to run.
 Application Execution: When you run a program or application, it is loaded
into RAM to be executed by the CPU. Without RAM, the CPU would have
nowhere to fetch the program's instructions and data from, and the
program would not run.

You might also like