0% found this document useful (0 votes)
22 views

Program 8bit

The document describes a program to subtract two 8-bit numbers in assembly language. It provides background on microprocessors and subtraction theory. It includes sections on flowcharts, code, simulation, results and questions.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Program 8bit

The document describes a program to subtract two 8-bit numbers in assembly language. It provides background on microprocessors and subtraction theory. It includes sections on flowcharts, code, simulation, results and questions.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

EI-37006 Microprocessor Systems- Lab work 2022

Program 4
1. Aim
Write an Assembly language program for subtraction of two 8-bit numbers.

2. Introduction

Microprocessor: A silicon chip that contains a CPU. In the world of personal computers,
the terms microprocessor and CPU are used interchangeably. A microprocessor
(sometimes abbreviated µP) is a digital electronic component with miniaturized
transistors on a single semiconductor integrated circuit(IC).

One or more microprocessors typically serve as a central processing unit (CPU) in a


computer system or handheld device. Microprocessors made possible the advent of the
microcomputer. At the heart of all personal computers and most working stations sits a
microprocessor. Microprocessors also control the logic of almost all digital devices,
from clock radios to fuel-injection systems for automobiles.

Three basic characteristics differentiate microprocessors:


1. Instruction set: The set of instructions that the microprocessor can execute.
2. Bandwidth: The number of bits processed in a single instruction.
3. Clock speed: Given in megahertz (MHz), the clock speed determines how many
instructions per second the processor can execute.

3. Theory
1.ORG Addr. Directive reserves the starting address for Program Code or data in
specified memory array,
2. LXI H (LOAD REGISTER PAIR IMMEDIATELY) loads 16 bit data in register pair
designated by operand.
3. LHLD Addr. (LOAD HL PAIR DIRECT) loads 16 bit data from specified address to

Department of Electronics & Instrumentation


EI-37006 Microprocessor Systems- Lab work 2022
designate in register pair.
4. MOV A, M copies the data byte into accumulator from the memory specified by the
address in H-L pair.
5. MVI (MOVE IMMEDIATE DATA) moves immediate value to specified register.
6. SBB instruction subtracts specified register content and carry flag to Accumulator
and store results into Accumulator.
7. JNC Addr. Instruction jump the execution to the specified Address if carry flag is
reset.
8. INR instruction increment the specified register content by 1.
9. INX H (INCREMENT REGISTER PAIR) increments the contents of the register pair
by one.
10. SUB M (SUBTRACTION) subtracts the contents of register to accumulator.
11. STA address (STORE ACCUMULATOR DIRECT) copies the contents of the
accumulator to the memory location specified in the instruction
12. SHLD Addr. (STORE HL DIRECT) instruction store HL pair content to specified
address.
13. RST 1 (RESTART) finishes the execution of the current instruction and stops any
further execution.

4. Flow Chart

Department of Electronics & Instrumentation


EI-37006 Microprocessor Systems- Lab work 2022

Department of Electronics & Instrumentation


EI-37006 Microprocessor Systems- Lab work 2022

5. Code
6. Simulation
7. Result
8. Questionnaire
Q1. What is the use of ALE?
Q2. Explain the signals HOLD, READY and SID.
Q3. What is the use of bidirectional buffer?

Q4. Give the register organization of 8085?


Q5. Which are the important interfacing chips of a microprocessor?
Q6. What are the functions of an accumulator?

Program 5
Department of Electronics & Instrumentation
EI-37006 Microprocessor Systems- Lab work 2022
1. Aim:

Write an assembly language program for finding square root of a number.

2. Introduction:

Interrupt is a mechanism by which an I/O or an instruction can suspend the normal


execution of processor and get itself serviced. Generally, a particular task is assigned
to that interrupt signal. In the microprocessor based system the interrupts are used for
data transfer between the peripheral devices and the microprocessor. The processor
will check the interrupts always at the 2nd T-state of last machine cycle.

Interrupt Service Routine (ISR):-A small program or a routine that when executed
services the corresponding interrupting source is called as an ISR.

Maskable/Non-Maskable Interrupt: - An interrupt that can be disabled by writing


some instruction is known as Maskable Interrupt otherwise it is called Non-Maskable
Interrupt.

There are 6 pins available in 8085 for interrupt:


TRAP
RST 7.5
RST6.5
RST5.5
INTR
INTA

Execution of Interrupts:-
When there is an interrupt requests to the Microprocessor then after accepting the
interrupts Microprocessor send the INTA (active low) signal to the peripheral. The
vectored address of particular interrupt is stored in program counter. The processor
executes an interrupt service routine (ISR) addressed in program counter.

Department of Electronics & Instrumentation


EI-37006 Microprocessor Systems- Lab work 2022
3. Theory
1. MOV A, M copies the data byte into accumulator from the memory specified
by the address in H-L pair.
2. MVI (MOVE IMMEDIATE DATA) moves immediate value to specified
register.
3. DAD instruction Add specified register pair content to HL pair content and
store results into HL pair.
4. SUB (SUBTACTION) subtracts register content to accumulator and stores
result into accumulator.
5. CMP (COMPARE WITH ACCUMULATOR) compares the register/memory
content to accumulator
If (A) < (Reg/Mem) ; carry flag is set and zero flag is reset.
If (A) = (Reg/Mem) ; carry flag is reset and zero flag is set.
If (A) > (Reg/Mem) ; both carry flag and zero flag are reset.
6. JZ Addr. instruction jump the execution to the specified Address if zero flag is
set.
7. JMP (JUMP UNCONDITIONAL) instruction jump the execution to the
specified Address
8. RAL (ROTATE ACCUMULATOR LEFT THROUGH CARRY)
9. DCR instruction decrement the specified register content by 1.
10. ADD M (ADDTION) adds the contents of memory to accumulator.
11. STA address (STORE ACCUMULATOR DIRECT) copies the contents of the
accumulator to the memory location specified in the instruction
12. SHLD Addr. (STORE HL DIRECT) instruction store HL pair content to
specified address.
13. JNC Addr. (JUMP IF NO CARRY) jump to specified address if carry flag
reset.
14. RST 1 (RESET) finishes the execution of the current instruction and stops any
further execution.
15. DB Directive is defined to store values in specified memory array.

4. Flow chart
Department of Electronics & Instrumentation
EI-37006 Microprocessor Systems- Lab work 2022

5. Procedure
1. Write the program code on editor file window.
2. Store some input data at specified Memory Array.
3. Click on the option Assemble for simulation.
4. Write the starting address of the program to simulate option.
Department of Electronics & Instrumentation
EI-37006 Microprocessor Systems- Lab work 2022
5. Simulation of entire code could be run at a time or step by step.
6. Execution results can be checked through the Register, Memory and Device
environment window.
6. Note down updated register and memory content value for verification of result.

6.Code

7. Simulation
8. Result
9. Questionnaire

Q1. Explain the concept of pipelining with reference to microprocessor


Q2. What is memory mapping in microprocessor?
Q3. What is mnemonics in microprocessor?
Q4. Difference between microprocessor and microcontroller
Q5. Differentiate latch & tri state buffer
Q6.. What is an op-code &Operand?

Program no. 6
1.Aim -
Write an assembly language program to multiply two 8-bit numbers

2.Introduction-
Department of Electronics & Instrumentation
EI-37006 Microprocessor Systems- Lab work 2022

The 8085 has no multiplication operation. To get the result of multiplication, we should use the
repetitive addition method.
After multiplying two 8-bit numbers it may generate 1-byte or 2-byte numbers, so we have to use two
registers to hold the result.

3.Theory –
1) MVI (MOVE IMMEDIATE DATA) - Moves immediate value to
specified register.
2) ADD M (ADDTION) - Adds the contents of memory to accumulator
3) JNC Addr.(JUMP IF NO CARRY) - Instruction jump the execution to the
specified Address if carry flag is reset.
4) INR R(INCREMENT REGISTER) - Increment the specified register
content by 1.
5) STA addr. (STORE ACCUMULATOR DIRECT) - Copies the contents
of the accumulator to the memory location specified in the instruction
6) JNZ (CONDITIONAL JUMP) The program sequence is transferred to a
particular level or a 16-bit address if Z=0 (or zero flag is 0)
7) MOV A, M - Copies the data byte into accumulator from the memory
specified by the address in H-L pair.
8) DCR C - Used to decrement value at C register by one
9) LXI ,H (LOAD REGISTER PAIR IMMEDIATELY) - Loads 16 bit data
in register pair designated by operand.

4. Flow chart -

Department of Electronics & Instrumentation


EI-37006 Microprocessor Systems- Lab work 2022

5. Code -

6.Simulation -

7.Result for execution –

Questionnaire -

Q1) Explain data-width


Q2) While handling interrupt instructions in 8086, what are the internal
operations carried out by stack?
Q3) What is BHE?
Q4) Discuss branch related addressing modes in 8086
Q5) Give the significance of instruction pointer

Department of Electronics & Instrumentation


EI-37006 Microprocessor Systems- Lab work 2022

Program no. 7

1.Aim -
Determine largest number in an array of n elements. Value of n is stored at address
2050 and array starts from address 2051. Result is stored at address 3050. Starting
address of program is taken as 2000.

2. Introduction-

Algorithm-

1. We are taking first element of array in A


2. Comparing A with other elements of array, if A is smaller then store that element in
A otherwise compare with next element
3. The value of A is the answer

3.Theory –
1) LXI H (LOAD REGISTER PAIR IMMEDIATELY) - Loads 16 bit data
in register pair designated by operand.
2) MOV C, M (MOVE M TO C) - Copies the data byte into C from the
memory specified by the address in H-L pair.
3) INX H (INCREMENT REGISTER PAIR) - Increments the contents of
the register pair by one.
4) MOV A, M (MOVE M TO A) - Copies the data byte into accumulator
from the memory specified by the address in H-L pair.
5) MOV B, M (MOVE M TO B) - Copies the data byte into B from the
memory specified by the address in H-L pair.
6) CMP B - Subtracted the contents of register B from the accumulator
Department of Electronics & Instrumentation
EI-37006 Microprocessor Systems- Lab work 2022
content A and the result store in A.
7) DCR C - Used to decrement value at C register by one
8) JNZ - Stands for jump if not zero.
9) MOV M, r - Will copy 8-bit value from the register r to the memory
location as pointed by HL register pair

4.Flow chart

Department of Electronics & Instrumentation


EI-37006 Microprocessor Systems- Lab work 2022

5.Code:

6.Simulation -

7.Result for execution –

Questionnaire
Q1) What is Tri-state logic?

Q2) Can an RC circuit is used as clock source for 8085?


Q3) Why crystal is a preferred clock source?
Q4) What is the function of IO/M signal in the 8085?

Department of Electronics & Instrumentation


EI-37006 Microprocessor Systems- Lab work 2022

Program no. 8

1.Aim -
Determine smallest number in an array of n elements. Value of n is stored at address 2060
and array starts from address 2061. Result is stored at address 3060. Starting address of
program is taken as 2000.

2.Theory –
1) LXI H (LOAD REGISTER PAIR IMMEDIATELY) - Loads 16 bit data
in register pair designated by operand.
2) MOV C, M (MOVE M TO C) - Copies the data byte into C from the
memory specified by the address in H-L pair.
3) INX H (INCREMENT REGISTER PAIR) - Increments the contents of
the register pair by one.
4) MOV A, M (MOVE M TO A) - Copies the data byte into accumulator
from the memory specified by the address in H-L pair.
5) DCR C - Used to decrement value at C register by one
6) MOV B, M (MOVE M TO B) - Copies the data byte into B from the
memory specified by the address in H-L pair.
7) CMP B - Subtracted the contents of register B from the accumulator
content A and the result store in A.
8) DCR C - Used to decrement value at C register by one
9) JNZ - Stands for jump if not zero.
10) MOV M, r - Will copy 8-bit value from the register r to the memory
location as pointed by HL register pair
11) HLT - Is used to terminate the program

Department of Electronics & Instrumentation


EI-37006 Microprocessor Systems- Lab work 2022

3.Flow chart -

Department of Electronics & Instrumentation


EI-37006 Microprocessor Systems- Lab work 2022

4.Code –

5.Simulation -

6.Result for execution

7. Questionnaire
Q1. Explain data-width
Q2. While handling interrupt instructions in 8086, what are the internal
operations carried out by stack?
Q3. What is BHE?
Q4. Discuss branch related addressing modes in 8086
Q5. Give the significance of instruction pointer

Department of Electronics & Instrumentation


EI-37006 Microprocessor Systems- Lab work 2022

Program no. 9

1. Aim -
Write an Assembly language program to convert BCD to binary

2.Introduction -
Binary Coded Decimal, or BCD, is another process for converting decimal numbers into
their binary equivalents.

 It is a form of binary encoding where each digit in a decimal number is represented in the
form of bits.
 This encoding can be done in either 4-bit or 8-bit (usually 4-bit is preferred).
 It is a fast and efficient system that converts the decimal numbers into binary numbers as
compared to the existing binary system.
 These are generally used in digital displays where is the manipulation of data is quite a
task.
 Thus BCD plays an important role here because the manipulation is done treating each
digit as a separate single sub-circuit.

3.Theory-
1. Load the BCD number in the accumulator
2. Unpack the 2 digit BCD number into two separate digits. Let the left digit be BCD and
1

the right one BCD 2

3. Multiply BCD by 10 and add BCD to it


1 2

If the 2 digit BCD number is 72, then its binary equivalent will be
7 x OAH + 2 = 46H + 2 = 48H
Steps:
1. Load the BCD number from the memory location (201FH, arbitrary choice) into the
accumulator
2. Temporarily store the accumulator’s value in B
3. Obtain BCD by ANDing the accumulator with 0FH and store it in C
2

4. Restore the original value of the accumulator by moving the value in B to A. AND the
accumulator with F0H
Department of Electronics & Instrumentation
EI-37006 Microprocessor Systems- Lab work 2022
5. If the value in the accumulator equals 0, then BCD is the final answer and store it in the
2

memory location, 2020H (arbitrary)


6. Else, shift the accumulator to right 4 times to obtain BCD . Next step is to multiply
1

BCD by 0AH
1

7. Multiplication: Move BCD to D and initialise E with 0AH as the counter. Clear the
1

accumulator to 0 and add D to it E number of times


8. Finally, add C to the accumulator and store the result in 20

1. ORG Address (ORIGIN) - Directive reserves the starting address for


program Code or data in specified memory array.
2. LXI H (LOAD REGISTER PAIR IMMEDIATELY) - Loads 16 bit data
in register pair designated by operand.
3. LHLD Addr. (LOAD HL PAIR DIRECT) - Loads 16 bit data from
specified address to designate in register pair..
4. DAD (DOUBLE ADDITION) - Add specified register pair content to HL
pair content and store results into HL pair.
5. JNC Addr.(JUMP IF NO CARRY) - Instruction jump the execution to the
specified Address if carry flag is reset.
6. INR R(INCREMENT REGISTER) - Increment the specified register
content by 1.
7. INX H (INCREMENT REGISTER PAIR) - Increments the contents of
the register pair by one.
8. ADD M (ADDTION) - Adds the contents of memory to accumulator.
9. STA addr. (STORE ACCUMULATOR DIRECT) - Copies the contents
of the accumulator to the memory location specified in the instruction
10. SHLD Addr. (STORE HL DIRECT) - Instruction store HL pair content
to specified address.
11. RST 1 (RESET) - Finishes the execution of the current instruction and
stops any further execution.
12. DB (DEFINE BYTE) - Directive is defined to store values in specified
memory array

Department of Electronics & Instrumentation


EI-37006 Microprocessor Systems- Lab work 2022
4.Flowchat-

Department of Electronics & Instrumentation


EI-37006 Microprocessor Systems- Lab work 2022

5.Code –

6.Simulation -

7.Result for execution


Questionnaire -

Q1) What is Tri-state logic?

Q2) Can an RC circuit is used as clock source for 8085? Q3)


Why crystal is a preferred clock source?
Q4) What is the function of IO/M signal in the 8085?
Q5) What is the difference between assembly language and high level language?

Department of Electronics & Instru. Engg.Page 20

You might also like