MICRO1
MICRO1
Explain
with the instruction set example in 8085 microprocessors.
In the 8085 microprocessor, addressing modes define how the operand (data to be used) is
specified in an instruction. Let's explain the two modes: Direct Addressing Mode and Immediate
Addressing Mode, with examples.
In direct addressing mode, the address of the operand (data) is explicitly specified in the instruction.
The microprocessor fetches the data from the memory location given in the instruction.
Example:
LDA 2500H
Explanation:
o Here, LDA (Load Accumulator) is the instruction to load a value into the accumulator.
o 2500H is the direct memory address (in hexadecimal) where the data to be loaded is
stored. The microprocessor fetches the data from this memory location and stores it in
the accumulator (A register).
Summary: In direct addressing, the operand is stored at a specific memory location, and that
location is provided directly in the instruction.
In immediate addressing mode, the operand (data) is specified explicitly in the instruction itself,
rather than from a memory location.
Example:
MVI A, 32H
Explanation:
o 32H is the immediate data (in hexadecimal) to be loaded into the accumulator.
Summary: In immediate addressing mode, the operand is part of the instruction, and the
microprocessor doesn't need to fetch data from memory.
Key Differences:
Direct Addressing Mode: Operand is in memory; the instruction specifies the memory location.
MVI C,05H
LOOP: DCR C
JNZ LOOP
RST3
The instruction RLC (Rotate Accumulator Left) in the 8085 microprocessor rotates the contents
of the accumulator one bit to the left, with the carry involved in the rotation.
The 8085 microprocessor uses addressing modes to specify how the operand (data) is selected
in an instruction. Each mode provides flexibility in accessing operands, which can be stored in
registers, memory locations, or within the instruction itself.
Addressing Modes of 8085:
There are five main types of addressing modes in the 8085 microprocessor:
1. Immediate Addressing Mode
2. Register Addressing Mode
3. Direct Addressing Mode
4. Indirect Addressing Mode
5. Implicit (Implied) Addressing Mode
LXI 3 OF MR MR
5. If CLK frequency is 3.5 MHZ for 8085, find the execution time for MOV A, B
and LDA 8700H.
To calculate the execution time of instructions in the 8085 microprocessor, you need to know two
things:
Final Results:
MOV A, B execution time = 1.14 microseconds
LDA 8700H execution time = 3.71 microseconds
6. What is a subroutine?
7. What is the use of CALL and RET instructions? Give an example each for CALL and RET
instruction. Ans:- (SAME AS 6)
Classification of Interrupts
Maskable Non-Maskable
Maskable interrupts are those interrupts which The interrupts which are always in enabled mode
can be enabled or disabled. are called non-maskable interrupts.
RST 7.5 RST 6.5 RST 5.5 INTR TRAP
Vectored Non-Vectored
The interrupts which have fixed memory location The interrupts which don't have fixed memory
for transfer of control from normal execution. location for transfer of control from normal
Each vectored interrupt points to the particular execution.
location in memory.
RST 7.5 RST 6.5 RST 5.5 TRAP INTR
1. Vectored Interrupt
In a Vectored Interrupt, the address of the interrupt service routine (ISR) is predefined and is
automatically provided by the hardware as soon as the interrupt occurs. When the interrupt is
triggered, the processor immediately jumps to a specific address, known as the interrupt vector,
where the ISR is located.
2. Non-Vectored Interrupt
In a Non-Vectored Interrupt, the address of the interrupt service routine (ISR) is not predefined.
Instead, the processor requires the external device to provide the address of the ISR, usually by
sending the address through data lines or by using some additional mechanism. The processor
does not know where to jump for the ISR without receiving this information.
Significance of TRAP
Emergency Handling: TRAP is used for handling critical or emergency situations in a system, such
as: Power failure. System shutdown. High-priority errors.
Uninterruptible: Since TRAP cannot be masked or ignored, it ensures that the processor always
responds to critical conditions.
Reliable Interrupt: Its dual nature (level and edge sensitivity) ensures reliability, reducing the
chance of missing the interrupt.
Fixed ISR Location: The predefined vector address (0024H) simplifies the implementation of the
interrupt routine.
Example:
A TRAP interrupt can be used in systems where:
A power failure signal triggers the processor to save critical data to non-volatile memory before
shutting down.
Program:
LXI H, 5000H ; Load HL with address 5000H (starting address of Number 1)
MOV A, M ; Load A with the lower byte of Number 1 (5000H)
INX H ; Increment HL to point to 5001H (upper byte of Number 1)
MOV B, M ; Store upper byte of Number 1 in register B
LDA 4001H ; Load the second number from memory location 4001H into accumulator A
SUB B ; Subtract the value in register B (minuend) from accumulator A (subtrahend)
13. Illustrate a (256 x 8) bytes memory register considering the chip select to be the active low.
Draw the hardware and specify the possible address range.
14. Draw and explain the table for 8085 that how IO/M’ read and write, opcode fetch and interrupt
acknowledge are selected using select lines.
15.What is DMA?
Direct Memory Access (DMA) uses hardware for accessing the memory, that hardware is called
a DMA Controller. It has the work of transferring the data between Input Output devices and
main memory with very less interaction with the processor. The direct Memory Access
Controller is a control unit, which has the work of transferring data.
Explanation: The CPU initializes the DMA by sending the given information through the data
bus.
The starting address of the memory block where the data is available (to read) or where data
are to be stored (to write).
It also sends word count which is the number of words in the memory block to be read or
written.
Control to define the mode of transfer such as read or write.
A control to begin the DMA transfer
Applications:
17. Write simple programs to generate delay using these different methods.
SEARCH_LOOP:
MOV A, M ; Move the content of the memory (pointed by HL) into register A
CPI 40H ; Compare the content of A with 40H
JZ FOUND ; If A = 40H, jump to FOUND label
INX H ; Increment HL to point to the next memory address
DCR B ; Decrement the counter
JNZ SEARCH_LOOP ; If counter B is not zero, repeat the loop
FOUND:
HLT ; Halt the program if 40H is found
Explanation:
1. LXI H, 8000H: Loads the starting memory address 8000H into the HL register pair.
2. MVI B, 04H: Initializes the counter B with 4 because we need to check four memory locations
(8000H, 8001H, 8002H, 8003H).
3. MOV A, M: Moves the content of the memory location pointed to by HL into the accumulator A.
4. CPI 40H: Compares the value in A with 40H.
o If equal, the Zero (Z) flag is set, and the program jumps to the FOUND label.
5. INX H: Increments HL to point to the next memory location.
6. DCR B: Decreases the counter B by 1.
7. JNZ SEARCH_LOOP: If B is not zero, it jumps back to the SEARCH_LOOP to check the next
memory location.
8. HLT: If 40H is found, or if all locations have been checked and 40H was not found, the program
halts.
This program checks the memory from 8000H to 8003H and halts if 40H is found at any of those
locations.
22.Write a program to store first 10 Fibonacci numbers to memory address
starting from 9050H.
23.Define all the flags in 8085.
The purpose of flags in the 8085 microprocessor is to indicate the outcome of an operation
performed by the Arithmetic Logic Unit (ALU). These flags are bits in the flag register that reflect
the status of the processor after an arithmetic or logical operation, influencing subsequent
instructions (e.g., conditional jumps).
Flags in 8085
The 8085 flag register is an 8-bit register, but only 5 bits are used as flags:
Bit Name Description
Summary Table
Flag Name Bit Set Condition
25. Explain the operation of the instruction set: 8000: LXI B, 9200H
(2nd pdf)
1. JP (Jump if Positive)
Function: Transfers program control to the specified memory address if the Sign Flag (S) is reset
(i.e., S = 0). This occurs when the result of the previous operation is positive or zero.
Syntax: JP address
Condition: If S=0S = 0S=0, jump to the specified address.
Example: If the result of an arithmetic operation is positive (e.g., the MSB of the accumulator is
0), this instruction jumps to the specified address.
Summary Table
Instruction Condition Flag Involved Description
JPE P=1P = 1P=1 Parity Flag (P) Jump if the parity is even.
JPO P=0P = 0P=0 Parity Flag (P) Jump if the parity is odd.
JNZ Z=0Z = 0Z=0 Zero Flag (Z) Jump if the result is not zero.
30.Explain the programming model of the 8085 microprocessor along with all
its segments.
1. Registers
Definition: Registers are small storage units inside the microprocessor that hold data
temporarily for processing.
Types of Registers:
o General-Purpose Registers: B, C, D, E, H, L (8-bit registers).
Can be used individually or as 16-bit register pairs (BC, DE, HL) for operations
like addition, subtraction, and memory addressing.
o Temporary Register: Used internally by the processor; not accessible to the
programmer.
2. Accumulator (A Register)
Definition: An 8-bit special-purpose register used for arithmetic, logic, and data transfer
operations.
Function:
o Acts as the primary register for storing intermediate results.
o Works with the ALU for arithmetic and logical operations.
3. Flags
Definition: A 5-bit register that reflects the outcome of operations.
Components:
o Sign Flag (S): Set if the result is negative.
o Zero Flag (Z): Set if the result is zero.
o Auxiliary Carry Flag (AC): Set if there is a carry from bit 3 to bit 4 (used in BCD
operations).
o Parity Flag (P): Set if the number of 1s in the result is even.
o Carry Flag (CY): Set if there is a carry out or borrow in the result.
Summary Table
Component Size Function
31.What is the purpose of flag? Define all the flags in 8085. (same as 23)
LOOP: DCX B
MOV A, C
ORA B
JNZ LOOP
39.Write a program to search 80H in the given memory address set. If found
terminate the program. 9000: 01; 9001:80; 9002:40; 9003: 78
MVI H, 90H ; Load HL pair with starting memory address 9000H (90H in H and 00H in L)
MVI L, 00H
MVI D, 80H ; Load register D with the value to search for (80H)
SEARCH:
FOUND:
Explanation:
1. MVI H, 90H: Load H register with 90H (the high byte of the starting address 9000H).
2. MVI L, 00H: Load L register with 00H (the low byte of the starting address 9000H).
3. MVI D, 80H: Load D register with the value to search for, which is 80H.
4. SEARCH: The label for the loop that checks each memory location.
o MOV A, M: Move the content of the memory location pointed to by HL into the
accumulator.
o CMP D: Compare the accumulator with the value in D register (which is 80H).
o JZ FOUND: If the value in memory equals 80H, jump to the FOUND label (terminating
the program).
5. INX HL: Increment HL so that it points to the next memory location (9001H → 9002H → 9003H).
6. MOV A, L: Move the value in L register (the low byte of the memory address) into the
accumulator.
o CPI 03H: Compare the L register value to 03H, which is the offset for the last address to
check (9003H).
o JZ NOT_FOUND: If all addresses have been checked, jump to the NOT_FOUND label.
7. JMP SEARCH: Repeat the search for the next memory location.
8. FOUND: If 80H is found, jump to this label and HLT to halt the program.
9. NOT_FOUND: If the value 80H is not found in the memory range, it will also halt the program.
40.If CLK frequency is 3.5 MHZ for 8085, find the execution time for SHLD
9200H and LDA 8700H.
41.What is stack memory? Explain the PUSH, POP instruction.
42.Explain the operation of the instruction SUB L, SBB H, STA 9000H, SHLD
8000H, RRC, JNC.
1. SUB L
Syntax: SUB L
Flags Affected:
2. SBB H
Operation: Subtracts the contents of register H and the carry flag (CY) from the accumulator (A).
Syntax: SBB H
3. STA 9000H
Operation: Stores the contents of the accumulator (A) into the memory location 9000H.
Steps:
4. SHLD 8000H
Operation: Stores the contents of register pair HL into two consecutive memory locations
starting at 8000H.
Steps:
Operation: Rotates the bits of the accumulator (A) one position to the right.
Syntax: RRC
Details:
1. The least significant bit (D0) is moved to the most significant bit (D7) and also to the
carry flag (CY).
Flags Affected:
Operation: Transfers control to the specified address if the carry flag (CY) is reset (CY = 0).
Steps:
1. If CY = 0, the program counter (PC) is updated with the specified address, and the
program jumps to that location.
Example: If the carry flag is reset, the instruction will jump to the address provided.
Summary of Operations
Instruction Operation
SHLD 8000H Stores register pair HL in memory locations 8000H and 8001H.
To generate a pulse of 50 µs using Counter 0 of the 8254 programmable interval timer, we need to
calculate the counter value, write the appropriate control word, and develop the necessary subroutine.
Here's a step-by-step explanation:
3. Subroutine
assembly
Copy code
; Initialize 8254 for Counter 0 pulse generation
MOV AL, 20H ; Control word for Counter 0, Mode 0, LSB only
WAIT:
Explanation of Code
1. Control Word: The value 20H20H20H initializes Counter 0 in Mode 0 and selects LSB-only
read/write.
2. Load Counter: The value 64H64H64H (100 in decimal) is loaded as the initial count.
3. Wait for Pulse: The program waits until Counter 0 reaches 0 by continuously checking the
current value of the counter.
45.Write the BSR control word and subroutine in 8255 to set PC1 and PC3,
after 10 us reset those bits.
46.In 8255 I/O mode 8 push buttons are connected to port A and one seven
segment display connected to port C. Port B acts as i/p port. Write the
control word and draw the hardware. Consider o/p port=0, i/p port= 1.
47.WAP to transfer ten 8-bit numbers from 8050H to 9050H.
8050: 01, 8051: 02, …. 8059:0A
To write a program to transfer ten 8-bit numbers from 8050H to 9050H in the 8051 microcontroller,
we'll perform the following steps:
LOOP:
MOV A, @DPTR ; Load 8-bit number from source
MOV DPTR, #9050H ; Load destination address (9050H) into DPTR
MOV @DPTR, A ; Store the number to destination
INC DPTR ; Increment source address (8050H)
INC DPTR ; Increment destination address (9050H)
INC R0 ; Increment counter
CJNE R0, #10, LOOP ; Loop until 10 numbers are transferred
48.Practice decoding out the output programs done in the class. You should
be able to write the final output after the given set of instructions.
The Program Status Word (PSW) in the 8051 microcontroller is a 1-byte register that contains
information about the state of the microcontroller at any given point during the execution of a program.
It plays a crucial role in the functioning of the 8051 as it stores various status flags that provide
information about the last arithmetic and logical operations performed by the microcontroller.
Components of PSW:
The PSW is divided into two parts:
o Carry Flag (C): Indicates if the last arithmetic or logic operation resulted in a carry.
o Auxiliary Carry Flag (AC): Used for binary-coded decimal (BCD) operations.
o Sign Flag (S): Represents the most significant bit of the result, indicating the sign of the
result (negative if set).
o Parity Flag (P): Indicates if the result has an even number of 1s (set) or an odd number
(reset).
o Register Bank Select (RS1, RS0): These bits are used for switching between different
register banks (only RS0 is used in 8051).
o Interrupt Enable Flag (IE): Indicates whether interrupts are enabled (0) or disabled (1).
o This bit reflects the contents of the accumulator at any given point
An instruction cycle is the total time required by the microprocessor to fetch, decode, and execute an
instruction. It consists of several steps:
In short, the instruction cycle involves all the operations needed to complete one instruction.
Machine Cycle:
A machine cycle is a part of the instruction cycle. It refers to the time required to complete one basic
operation (such as reading from memory, writing to memory, or fetching an instruction). Each
instruction may take multiple machine cycles to complete.
For example, an instruction like MOV A, B might require one machine cycle, while a more complex
instruction like LDA 2000H (load data from memory) requires multiple machine cycles (fetch, memory
read).
Key Difference:
A machine cycle is the basic unit of time for executing a single operation like fetching or
memory access.
51.Explain the function of ALU and IO/M signals in the 8085 architecture?
Function of ALU (Arithmetic Logic Unit) in 8085 Architecture:
The ALU (Arithmetic Logic Unit) is a critical component of the 8085 microprocessor responsible for
performing arithmetic and logical operations. Key functions include:
1. Arithmetic Operations:
2. Logical Operations:
o Carries out logical operations like AND, OR, XOR, and NOT (complement).
3. Comparison:
o Compares two values and sets flags based on the result (zero, carry, etc.).
o After each operation, the ALU updates the status flags (Zero, Sign, Carry, Parity, Auxiliary
Carry), which indicate the result of the operation.
The IO/M signal is used to differentiate between memory and I/O operations in the 8085
microprocessor:
1. IO/M = 0:
2. IO/M = 1:
The IO/M signal helps the microprocessor identify whether it is accessing memory or interacting with
external input/output devices.
52.What is 8254? Discuss its various operating modes. What are its areas of
applications?
53.Write a program(8085) to multiply two 8-bit numbers.
54.Mention the purpose of STACK and delay. Explain the priority of interrupts
in 8085.
Purpose of Stack:
1. Saving Return Addresses: Used during subroutine calls to store the return address.
2. Storing Register Data: Temporarily saves register contents using PUSH and restores them with
POP.
3. Handling Nested Subroutines and Interrupts: Allows storing multiple return addresses.
Purpose of Delay:
2. Timing Control: Maintains accurate timing for tasks like blinking LEDs or sending data.
4. Generating Time Intervals: Creates specific delays for tasks like running motors or controlling
lights.