0% found this document useful (0 votes)
137 views26 pages

Revision Microprocessor PDF

This document contains questions and answers related to the 8085 microprocessor. Question 1 defines the flag bits of the 8085 and lists the four types of data transfer instructions. It also explains stacks, instruction cycles, machine cycles, and states. Question 2 develops assembly language programs to perform various data transfer operations. Question 3 explains enabling, disabling, and masking interrupts on the 8085 and develops a program to toggle a port using the RST7.5 interrupt as an event timer.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views26 pages

Revision Microprocessor PDF

This document contains questions and answers related to the 8085 microprocessor. Question 1 defines the flag bits of the 8085 and lists the four types of data transfer instructions. It also explains stacks, instruction cycles, machine cycles, and states. Question 2 develops assembly language programs to perform various data transfer operations. Question 3 explains enabling, disabling, and masking interrupts on the 8085 and develops a program to toggle a port using the RST7.5 interrupt as an event timer.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

PAST YEAR 2016/2017

SECTION A

Question 1
(a) List and describe the flag bits available in the 8085 microprocessor.

- Sign Flag (S): This flag is set if the result of an arithmetic operation is negative.

- Zero Flag (Z): This flag is set if the result of an arithmetic operation is zero.

- Auxiliary Carry Flag (AC): This flag is set if there is a carry from the lower nibble (4 bits) to
the upper nibble during an arithmetic operation.

- Parity Flag (P): This flag is set if the number of 1s in the result of an operation is even.

- Carry Flag (CY): This flag is set if there is a carry from the most significant bit during an
arithmetic operation.

(b) List all FOUR (4) types of data transfer group for the 8085 microprocessor instructions set. Give
an example of instruction for each type.

- Register-to-register transfer: These instructions transfer data from one register to another.
An example of this type of instruction is MOV A, B, which transfers the contents of register B
to register A.

- Register-to-memory transfer: These instructions transfer data from a register to memory.


An example of this type of instruction is MOV M, A, which transfers the contents of register
A to memory location pointed to by the HL register pair.

- Memory-to-register transfer: These instructions transfer data from memory to a register. An


example of this type of instruction is MOV A, M, which transfers the contents of the
memory location pointed to by the HL register pair to register A.

- Immediate-to-register transfer: These instructions transfer an immediate value (a constant


value specified in the instruction) to a register. An example of this type of instruction is MVI
A, 34h, which loads the hexadecimal value 34 into register A.
(c) What is a stack and what are the basic operations of a stack? What is meant by 'Last in First-
Out' (LIFO)?

- A stack is a linear data structure that implements a collection of elements, with two main
operations:

push: which adds an element to the top of the stack


pop: which removes the element from the top of the stack

- "Last-In First-Out" (LIFO) is a property of a stack, which means that the last element added
to the stack is the first one to be removed. This is due to the fact that elements are added
and removed from the top of the stack only.

(d) Explain instruction cycle, machine cycle and state.

- Instruction Cycle: The instruction cycle refers to the series of steps that the CPU follows in
order to execute a single instruction from a program. This cycle includes the following steps:

Fetch: The CPU retrieves the instruction from memory.


Decode: The CPU decodes the instruction to determine what it requires.
Execute: The CPU performs the operation specified by the instruction.
Store: The result of the operation is stored back in memory.

This cycle is repeated for every instruction in a program until the program terminates or is
interrupted.

- Machine Cycle: The machine cycle refers to the timing of the signals and operations within a
single instruction cycle. It defines the timing and sequence of signals that control the
transfer of data and the execution of instructions.

- State: The state of the CPU refers to the internal state of the processor at a particular point
in time, including the values stored in its registers, the status of its flags, and the location of
the current instruction. The state of the CPU changes as it executes instructions, and the
sequence of states that a CPU goes through during the execution of a program can be
thought of as a state machine.
(e) Sketch the timing diagram when the microprocessor fetches and execute the instruction MOV
M, A at memory location 1020H.

1. The microprocessor first fetches the instruction from memory location 1020H. The
instruction is stored in the instruction register (IR) of the microprocessor.

2. The microprocessor decodes the instruction to determine what operation it represents. In


this case, the instruction "MOV M, A" is a move instruction that transfers the contents of the
Accumulator (A) to the memory location pointed to by the HL register pair.

3. The microprocessor retrieves the contents of the Accumulator (A) and stores it in the
temporary register.

4. The microprocessor retrieves the memory address pointed to by the HL register pair and
stores it in the memory data register (MDR).

5. The microprocessor transfers the contents of the temporary register to the memory location
pointed to by the MDR.

6. The microprocessor increments the program counter (PC) to the next memory location,
which holds the next instruction to be executed.

7. The cycle repeats itself, with the next instruction being fetched and executed in a similar
manner.

Question 2
(a) Develop an assembly language program based on the following statement.

(i) Write value AAH to memory locations 4000H, 4002H and 4004H

MOV AX, AAH


MOV [4000H], AX
MOV [4002H], AX
MOV [4004H], AX

(ii) Data in B register is AND's with data in D register and the result is store to E register

AND B, D
MOV E, B
(iii) Exchange the contents of memory locations 3000H and 3002H.

MOV AX, [3000H]; //Load the contents of 3000H into AX


MOV BX, [3002H]; // Load the contents of 3002H into BX
MOV [3002H], AX; // Store the contents of AX into 3002H
MOV [3000H], BX; //Store the contents of BX into 3000H

(iv) Read two 8-bit data from port address FOH and FIH. Add both data and send to port
address F2H.

MOV AL, [FOH];// Read the first 8-bit data from port address FOH
ADD AL, [FIH]; //Read the second 8-bit data from port address FIH and add it to the first
data
MOV [F2H], AL; //Send the result to port address F2H

(b) Given the following sub-routine to convert two-digit BCD numbers in memory to the equivalent
HEX number.

(i) Translate the program into machine code manually.

1000: 21 00 10 LXI H,DATA


1003: 7E MOV A,M
1004: 87 ADD A
1005: 47 MOV B,A
1006: 87 ADD A
1007: 87 ADD A
1008: 80 ADD B
1009: 23 INX H
100A: 7E MOV A,M
100B: 23 INX H
100C: 77 MOV M,A
100D: C9 RET
8000: 00 00 00 00 DS 4

(ii) Calculate the executing time for the sub-routine if the 8085 microprocessor is driven by
5 MHz crystal.

The 8085 microprocessor has a clock speed of 5 MHz, meaning it can execute 5 million
clock cycles per second.

For the given sub-routine, the following is the number of clock cycles required by each
instruction:

LXI H,DATA: 3 clock cycles


MOV A,M: 7 clock cycles
ADD A: 4 clock cycles
MOV B,A: 5 clock cycles
ADD A: 4 clock cycles
ADD A: 4 clock cycles
ADD B: 4 clock cycles
INX H: 5 clock cycles
ADD M: 7 clock cycles
INX H: 5 clock cycles
MOV M,A: 7 clock cycles
RET: 10 clock cycles
Therefore, the total execution time of the sub-routine is:
3 + 7 + 4 + 5 + 4 + 4 + 4 + 5 + 7 + 5 + 7 + 10 = 55 clock cycles

To convert this to time, we divide the number of clock cycles by the clock speed of the
processor:
55 clock cycles / 5 million clock cycles per second = 0.000011 seconds or approximately
11 microseconds.
Question 3
(a)
(i) Explain the process of enabling, disabling and masking RST5.5, RST6.5 and RST 7.5 of the
8085 microprocessor interrupts.

The 8085 microprocessor has five maskable interrupts, including RST 5.5, RST 6.5, and RST 7.5.

- Enabling Interrupts:
To enable an interrupt in the 8085, the corresponding bit in the Interrupt Enable Register (IE)
must be set to 1. The IE register is an 8-bit register, and each bit in the register corresponds
to a specific interrupt. For example, to enable RST 5.5, the 3rd bit in the IE register must be
set to 1.

- Disabling Interrupts:
To disable an interrupt, the corresponding bit in the IE register must be set to 0. For example,
to disable RST 5.5, the 3rd bit in the IE register must be set to 0.

- Masking Interrupts:
Interrupts can also be masked by setting the Interrupt Mask Register (IMR). The IMR register
is also an 8-bit register and operates similarly to the IE register, with each bit corresponding
to a specific interrupt. To mask an interrupt, the corresponding bit in the IMR register must
be set to 1. When an interrupt is masked, it will not be executed even if it is enabled.

(iii) Figure 3.1 below show a continuous 100 Hz square wave signal is connected to RST7.S
interrupt pin. If the RST7.5 interrupt is enabled, the microprocessor will be interrupted
for every 10 ms. This technique is called event timer and can be used in timer-based
applications instead of software delay. Using this technique, develop a program to toggle
port peo ON and OFF for every 1 second.

(b) The basic microprocessor system is to be designed based on the following components

• 8085 microprocessor
• Two (2) unit of2K x 8 bit RAM started at location 4000H
• One (I) unit 4K x 8 bit EPROM started at location OOOOH

(i) Sketch the memory map.


Address Range Type of Memory

0000H to 1FFFH 4K x 8 bit EPROM

2000H to 3FFFH 2K x 8 bit RAM

4000H to 4FFFH 2K x 8 bit RAM

(ii) Design the decoding circuit for the memory system using any combinational logic or
decoder chip.

A15 ----|74138|---- RAM1_CS (Chip Select for RAM 1)


A14 ----| |---- RAM2_CS (Chip Select for RAM 2)
A13 ----| |---- EPROM_CS (Chip Select for EPROM)

(iii) Complete the wire connections of the components so that the basic system is functional.
You can add-on other components as needed.

1. Connect the data bus (D0-D7) and address bus (A0-A15) of the 8085 microprocessor
to the data bus and address bus of the EPROM, RAM1, and RAM2.

2. Connect the chip select (CS) signals from the decoding circuit to the chip select inputs
of the EPROM, RAM1, and RAM2.

3. Connect the read/write (R/W) signal from the 8085 to the R/W inputs of the EPROM,
RAM1, and RAM2.

4. Connect the ready signal from the RAM chips to the interrupt (INTR) pin of the 8085,
if needed.

5. Connect the power supply and ground connections to all components.

6. You may also need to connect the clock signal (CLK) from an oscillator to the 8085
and the memory chips.
SECTION B

Question 4
Figure 4.1 below shows an IC tester system based on 8085 microprocessor for an OR gate. The
microprocessor will output an 8-bit logic pattern at Port C to the input of the device and read the output
at Port B. The required 8-bit logic patterns generated in sequence by the microprocessor is based on the
OR gate truth table: 00000000, 01010101, 10101010 and 11111111. A common anode seven segment
display unit connected at Port A will display 'P' (PASS) if the gate is in good condition. Otherwise, it will
display 'F' (Fail) if the gate is in failure condition. The IC tester system will start to operate whenever the
pushbutton connected at PC7 is pressed.

(a) Sketch the complete interface circuit for pushbutton switch and seven segment display with
microprocessor system.
(b) Construct a flowchart or pseudo code for the system.

START
Initialize Port A as output for 7 segment displays
Initialize Port B as input for OR gate output
Initialize Port C as output for OR gate input
Clear Port C
Wait for pushbutton press at PC7
FOR i = 0 to 7
Output logic pattern at Port C based on OR gate truth table
Read output at Port B
Compare with expected result
If match, continue
If not match, display 'F' at Port A and go to END
END FOR
Display 'P' at Port A
END

(c) Develop an assembly language program to control the overall system.

; Initialize Ports
MVI C, 00h ; Clear Port C
OUT C ; Output to Port C
MVI B, 00h ; Clear Port B
IN B ; Input from Port B
MVI A, 0C0h ; Initialize Port A for 7 segment display
OUT A ; Output to Port A

; Wait for pushbutton press at PC7


WAIT:
IN B ; Input from Port B
ANI 80h ; Check PC7
JZ WAIT ; Repeat if PC7 not pressed

; Loop for OR gate truth table


FOR:
MVI C, 00h ; 00000000
OUT C ; Output to Port C
IN B ; Input from Port B
CMP 0 ; Compare with expected result
JNZ FAIL ; If not match, display 'F' and go to END
MVI C, 55h ; 01010101
OUT C ; Output to Port C
IN B ; Input from Port B
CMP 55h ; Compare with expected result
JNZ FAIL ; If not match, display 'F' and go to END
MVI C, AAh ; 10101010
OUT C ; Output to Port C
IN B ; Input from Port B
CMP FFh ; Compare with expected result
JNZ FAIL ; If not match, display 'F' and go to END
MVI C, FFh ; 11111111
OUT C ; Output to Port C
IN B ; Input from Port B
CMP FFh ; Compare with expected result
JNZ FAIL ; If not match, display 'F' and go to END
JMP FOR ; Repeat loop

; Display 'F' and go to END


FAIL:
MVI A, 066h ; Display 'F'
OUT A ; Output to Port A
JMP END

; Display 'P' and go to END


END:
MVI A, 0C0h ; Display 'P'
OUT A ; Output to Port A
HLT ; Halt program
PAST YEAR 2017/2018

SECTION A

Question 1
(a) Stack is temporary memory storage. Explain the method used to store the data in stack and
briefly explain the function of stack pointer.

(b) ORG 2000H


LXI SP,3000H
LXI B,0102H
LXID,0304H
PUSH B
PUSH D
POP B
POP D
END

(i) After executing this program, determine the content in register B, C, D and E

After executing these programs, the content in register B would be 0304H, in register C would
be undefined, in register D would be 0102H, and in register E would be undefined.

(ii) Based on programming, Specify the content of the stack by sketching a diagram of stack.
The stack diagram should contain the address and the data contain of stack.

Address | Data
2FFF | 0102H
2FFE | 0302H
2FFD | 0304H

Initially, the stack pointer SP points to address 3000H and the stack grows downwards, so
after pushing B and D onto the stack, the stack pointer moves downwards to address 2FFF
and the stack content is as shown above. When the POP instruction is executed, the data at
the top of the stack is popped out and loaded into the specified register, so the content of B
is 0304H and the content of D is 0102H.
(c) List and describe the flag bits available in the 8085 microprocessor.

- Sign flag (S): This flag indicates the sign of the result of an arithmetic operation. If the most
significant bit of the result is set, the sign flag is set, indicating a negative result. If the most
significant bit is clear, the sign flag is cleared, indicating a positive result.

- Zero flag (Z): This flag indicates whether the result of an arithmetic or logical operation is
zero. If the result is zero, the zero flag is set, indicating that the operation has produced no
result. If the result is non-zero, the zero flag is cleared.

- Carry flag (CY): This flag indicates whether an arithmetic operation has produced a carry out
of the most significant bit. If a carry occurs, the carry flag is set, indicating that the result has
overflowed. If no carry occurs, the carry flag is cleared.

- Parity flag (P): This flag indicates the parity of the result of an arithmetic or logical operation.
If the number of set bits in the result is even, the parity flag is set, indicating an even parity.
If the number of set bits is odd, the parity flag is cleared, indicating an odd parity.

- Auxiliary carry flag (AC): This flag indicates whether a carry has occurred from bit 3 to bit 4
during an arithmetic operation. This flag is used for BCD arithmetic. If a carry occurs, the
auxiliary carry flag is set, indicating that a correction should be made to the result. If no
carry occurs, the auxiliary carry flag is cleared.

(d) Explain program counter, instruction cycle, machine cycle and T-state.

- Program Counter (PC): It is a register in the CPU that stores the memory address of the next
instruction to be executed. It increments the address after each instruction is executed, so
that the next instruction is fetched and executed in the following cycle.

- Instruction Cycle: It is the complete process of fetching an instruction, decoding it, executing
it and storing the result in memory. It is also referred to as the fetch-decode-execute cycle.

- Machine Cycle: It is the time taken to complete one instruction cycle. It is made up of a
number of clock cycles and is dependent on the clock speed of the CPU.

- T-State: T-state is a term used in microprocessor architecture to describe a single cycle of


the clock. Each machine cycle is made up of a number of T-states, which are the basic units
of time used in the CPU.
PAST YEAR 2022
Question 1

(a) Briefly describe what is machine language programming and what language a microprocessor is
recognizes.

- Machine language programming, also known as machine code or assembly


language, is a low-level programming language used to write programs directly for a
computer's central processing unit (CPU). It consists of binary instructions that the
CPU can execute directly, without the need for further translation. Machine
language programming is considered to be the most basic form of programming, as
it is the language that the CPU understands.

- Microprocessor is a small, integrated circuit that contains the essential components


of a computer's central processing unit (CPU). It recognizes and executes machine
language instructions, which are typically represented in binary form as sequences
of 0s and 1s. The instruction set of a microprocessor determines the specific
machine language that it can understand and execute. Different microprocessors
have different instruction sets, and thus, recognize different machine languages.

(b) Instructions are stored in program memory in binary coded form.

(i) Describe the content of an instruction.

Opcode (Operation code): A binary code that specifies the operation to be


performed, such as addition, subtraction, load, store, jump, etc.

Operands: One or more binary codes that specify the data or memory location to
be operated on. For example, in an addition operation, the operands would
specify the two numbers to be added.

Address: An optional component that specifies the memory location where the
instruction is stored.
(ii) State an example each of the different types of instructions below:

a) Direct
An example of a direct instruction in a high-level programming language is a
move or copy operation, such as "MOVE X, Y" or "X = Y", which transfers the
value stored in one location (Y) to another location (X).

b) Immediate
An example of an immediate instruction in a high-level programming language
is a load constant operation, such as "LOAD #10", which loads a constant value
(10) into a register or memory location.

c) Implicit
An example of an implicit instruction in a high-level programming language is
a type coercion, such as "X = 10", where the value 10 is automatically
converted to the type of the target location (X). In this example, the type
coercion instruction is implicit and not explicitly stated in the code.

(c) Assembly language statements are written in standard format, explain each of the
standard format below with the support from any related example:

(i) Label
A label is a user-defined string that represents a location in memory where a
specific instruction or data value is stored. In assembly language, a label is used to
identify a specific memory address that can be referred to by other instructions.
The label is typically followed by a colon to distinguish it from other elements in
the instruction.

LOOP:
DELAY:

(ii) Mnemonic
A mnemonic is a short code that represents a specific machine instruction.
Mnemonics are used to make the assembly language instructions easier to read
and understand for humans.

MOV A, B
Mnemonic = MOV
(iii) Operand
An operand is a value that is used as input to an instruction. In assembly language,
an instruction typically requires one or more operands to specify the data that is
being operated on. The operand can be a register, memory address, or constant
value.

MOV B, 20H

Operand = 20H

(iv) Comment
A comment is a line of text that provides additional information about the code,
but is not executed as part of the program. Comments are used to explain the
purpose of a section of code or to provide additional information about a specific
instruction. In assembly language, comments are typically preceded by a
semicolon (;) or another special symbol to distinguish them from other parts of
the instruction.

MOV AX, BX ;// move the contents of BX into AX

• In this example, the comment "move the contents of BX into AX" provides
additional information about the purpose of the instruction.

(d) The program in Table 1 shows machine codes and memory locations to store the program. By
referring Appendix, A, convert the mnemonics given to the missing hex code and identify the
memory location each of the machine code stored.

Mnemonics Hex Code Memory Address


ORG 2000H - -
LXI 3FF0H OORP 0001 2000
MVI A, 82H 00DD D110 2003
OUT 83H D3 2005
MVI B, 48H OODD D110 2007
IN 82H DB 2009
ADD B 1000 0SSS 200A
CMA 2F 200B
OUT 80H D3 200D
RST 1 11XX X111 200E
Question 2
(a) The programmable peripheral chip input/output 8255A is a chip connected to the 8085
microprocessor. It allows the microprocessor to have more number of input / output ports.

(i) List ports available on this chip and state the address of each port.
Port A: 80H
Port B: 81H
Port C: 82H

(ii) Briefly explain the function of mode 0 and mode 1 in this 8255A chip.
Mode 0
- known as the basic input/output mode, which provides 8-bit input
and output operations.
- Port A can be used as an input port, Port B can be used as an output
port, and Port C is divided into two 4-bit sections, one for input and
one for output.

Mode 1
- known as the Strobed Input/Output mode, which provides 8-bit input
and output operations.
- Port A and Port B can be used as either input or output ports, while
Port C is divided into two 4-bit sections, one for input and one for
output. In this mode, the input and output operations are performed
under the control of a strobe signal.

(iii) Write a code to set all port to input port and using mode 0. Assume 8255 chip using 80H
as a base address.

MOV AL, 00H ; Mode 0 - Basic Input/Output


OUT 80H, AL ; Send Mode 0 to Control Register

(b) Interrupt is one of the functions in 8085 microprocessor.

(i) Briefly explain the definition of interrupt.

An interrupt is a signal to the microprocessor that temporarily stops the


execution of the current program and starts the execution of a specific
subroutine (interrupt service routine or ISR) in response to an external event.
The event could be an external hardware request, a timer event, or an I/O
operation completion, among others. The purpose of an interrupt is to allow
the microprocessor to respond to the event in a timely manner and return to
the previous program execution after the ISR is executed.
(ii) Write the a code to enable RST6.5 and RST7.5 and disable RST 5.5.

MVI C, 0C0H ; Load 0C0H into register C


OUT 0FFH ; Send the contents of C to port 0FFH

This code first loads the value 0C0H into register C, which represents the
enable/disable status of the interrupts. The bit values 1 and 0 indicate the
enable/disable status of each interrupt. The code sets bit 6 and 7 to 1 to enable
RST 6.5 and RST 7.5, respectively. It sets bit 5 to 0 to disable RST 5.5. Finally,
the code sends the contents of register C to port 0FFH, which is the interrupt
control register. This updates the interrupt enable/disable status.

(c) The 8085 microprocessor have two lines specially designed for serial data
transfer.

(i) Briefly explain TWO (2) types of serial transfer technique.

Asynchronous Serial Data Transfer: This method of serial data transfer uses starts
and stop bits to synchronize the transfer of data between the transmitting and
receiving devices. The start bit signals the beginning of the transmission, and the
stop bit signals the end. The data is transmitted one bit at a time.

Synchronous Serial Data Transfer: In this method, data is transferred in a


continuous stream without the use of start and stop bits. Instead, the transmitting
and receiving devices use a common clock signal to synchronize the transfer of
data. This method is faster than asynchronous serial data transfer, but it requires
a more complex circuit for synchronization.

(ii) By using 4800 bit/s as a baud rate and 10 MHz for value of crystal, write a
complete code to send a serial 8 bit data. Show your calculation as well.
; Initialize the serial port

MVI C, 38H ; Set the baud rate generator value to 38H

MVI B, 00H ; Clear the accumulator

OUT 0EH ; Send the value to port 0EH to set the baud rate
OUT 0FH ; Send the value to port 0FH to set the baud rate

; Send 8-bit data serially

MVI A, data ; Load the data to be transmitted into the accumulator

MOV B, A ; Copy the data to the accumulator B

RLC ; Rotate the accumulator left to send the first bit

OUT 10H ; Send the first bit to the serial port

; Repeat for the next 7 bits

RLC

OUT 10H

RLC

OUT 10H

RLC

OUT 10H

RLC

OUT 10H

RLC

OUT 10H

RLC

OUT 10H

CALCULATE BAUD RATE:

baud rate = crystal frequency / (16 * (baud rate generator value + 1))

Given the crystal frequency of 10 MHz and a baud rate of 4800 bit/s, we can calculate
the baud rate generator value as follows:

baud rate generator value = (crystal frequency / (16 * baud rate)) - 1

= (10 MHz / (16 * 4800 bit/s)) - 1


= 38H

Question 3
(a) Develop an assembly language program based on the following statement.

(i) Transfer the data from memory location 2100H to B register, 3100H to C register, then
do the “AND” operation value in B register with the value in C register, store the result
into memory location 4001H.

MOV BX, 2100H ; Move data from memory location 2100H to BX register
MOV CX, 3100H ; Move data from memory location 3100H to CX register
AND BX, CX ; Perform AND operation between BX and CX
MOV [4001H], BX ; Store result in memory location 4001H

(ii) By using minimum instruction, swap 4 bit lower with 4 bit upper data in memory
location 3500H and store the result into memory location 3501H .

MOV AX, [3500H] ; Move data from memory location 3500H to AX register
MOV BX, 0FH ; Move 0FH to BX register (used for masking)
AND AX, BX ; Mask the lower 4 bits of AX and store in AX
SHR AX, 4 ; Shift the masked lower 4 bits to right by 4 bits
MOV BX, [3500H] ; Move data from memory location 3500H to BX register
AND BX, 0F0H ; Mask the upper 4 bits of BX and store in BX
SHL BX, 4 ; Shift the masked upper 4 bits to left by 4 bits
OR AX, BX ; Perform OR operation between masked lower and upper bits
MOV [3501H], AX ; Store the result in memory location 3501H

(b) Delay is the most important sub-routine in 8085 microprocessor.

Delay: PUSH PSW


PUSH D
LXI D,0C671H
LOOP: DCX D
MOV A,D
ORA E
JNZ LOOP
POP D
POP PSW
RET

(i) By using 10 MHz crystal, calculate the total time needed to complete the delay sub-
routine. Refer to Appendix A.
(ii) By using the same crystal (10 MHz), modify the delay sub-routine to make a 250 mS
delay. Write the complete program of the new delay subroutine by using the assembly
language.

The average loop time can be estimated as:

Average loop time = (5 cycles + 5 cycles + 4 cycles + 10 cycles) / 2 = 15 cycles

The number of times the loop should run can be calculated as:

Number of times the loop runs = 250 milliseconds / (15 cycles / 10 MHz) = 166666.67

Since the number of times the loop runs needs to be an integer, we can round it up to
the nearest integer. Therefore, the number of times the loop should run is:

Number of times the loop runs = 166666.67 ≈ 167000

DELAY: PUSH PSW


PUSH D
LXI D,028FCH ; Load D with 167000
LOOP: DCX D ; Decrement D by 1
MOV A,D
ORA E
JNZ LOOP ; If D is not zero, jump back to LOOP
POP D
POP PSW
RET

(c) MVI A, 88H


LXI B, 3578H
ADD B

After executing this program, state the content of register flag.

S: 0 (No carry from bit 7)


Z: 0 (Result is not zero)
AC: 0 (No carry from bit 3)
P: 0 (Parity is even)
CY: 0 (No carry from bit 15)
So, the content of the register flag will be 0000H.

NOTE MICROPROCESSOR
CPU SEQUENCING

7 machine cycles:

Opcode Fetch - fetch the opcode of an instruction from memory

Memory Read - read data stored at an addressed memory location

Memory Write - write data to an addressed memory location

IO Read - read data from an addressed input device

IO Write - write data to an addressed output device

Interrupt Ack - acknowledge an interrupt request

Bus -Idle no bus operation

Find the time needed to process STA add. Instruction if frequency of oscillator = 10MHz

T state for STA = 13T

T =1/f

T =1/10MHz

Time to process =13x0.0000001s

=1.3uS

State Process Function:


• T1, T2, T3, T4, T5, T6, HALT STATE

HALT State
- The T-halt state is entered after execution of the HLT instruction. The
instruction is executed in the T4-state of the opcode fetch machine cycle by
the processor setting the internal halt flip-flop.

ASSEMBLY LANGGUAGE (INSTRUCTION SET)

Loop: MVI A, 20H ; move 20H into A

LOOP – LABEL

MVI – MNEMONIC

20H – OPERAND

move 20H into A – COMMENTS

Data Transfer Instruction

Move data between registers or between memory locations and registers. Includes
moves, loads, stores and exchanges.

Arithmetic Instruction

Adds, Subtracts, Increments, Decrements data in registers or memory.

Logic Instruction

ANDs, ORs, XORs, compares, rotates or complements data in registers or between


memory and registers.

Branch/Jump Instruction

Initiates conditional or unconditional jumps, calls, returns and restart.

Stack, I/O and Machine Control Instruction

Includes instructions for maintaining stack, reading from input port, writing to output
port, setting and reading interrupt mask and clearing flags.
Condition

JZ Z=1 Jump if Zero flag SET

JNZ Z=0 Jump if Zero flag NOT SET

JC CY=1 Jump if Carry flag SET

JNC CY=0 Jump if Carry flag NOT SET

JM S=1 Jump if Sign flag SET

JP S=0 Jump if Sign flag NOT SET

JPE P=1 Jump if Parity flag SET

JPO P=0 Jump if Parity flag NOT SET

INTERRUPTS
SERIAL COMMUNICATION

You might also like