You are on page 1of 49

King Khalid University Lab Manual

College of Computer Science Microprocessor & Assembly Language


Computer Science Program 343CSM -3

Microprocessor &
Assembly Language
Lab Manual

|Page 1
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Course Syllabus
Course Title Microprocessor and Assembly Language
Course Code 343 CSM -3

SYLLABUS AND SCHEDULE FOR THEORY COURSE


Text
Week Topic Chapter No. & Page No.
Reference
1 Introduction to Microprocessor I Ch. 1,2 & Pg No.3-31
2 Organization and Architecture of 8085 I Ch. 1,2 & Pg No.3-31
3 Functional block diagram, registers, ALU, bus I
Ch. 1,2 & Pg No.3-31
system, Pin Diagram
4 Timing and Control Signals I Ch. 4 & Pg No.96-115
5 Machine Cycles and Timing diagram for 8085 I Ch. 4 & Pg No.96-115
6 Instruction set- Data Transfer instructions I Ch. 6 & Pg No.175-186
7 Arithmetic operations I Ch. 6 & Pg No.186-196
8 Logic operations and Branch operations I Ch. 6 & Pg No.196-204
9 Programming techniques-looping, counting and I
Ch. 7 & Pg No.227-232
indexing
10 Additional data transfer instructions and 16-bit I
instructions. Arithmetic operations related to Ch. 7 & Pg No.232-238
memory
11 Logic operations, rotate, compare I Ch. 7 & Pg No.247-256
12 I/O and machine control instructions, 8085 I Ch. 5 & Pg No.140-145
Addressing Modes Ch. 6& Pg No.179
13 Interrupts I Ch. 12 & Pg No.375-390
14-15 Stack, Stack pointer, Program Counter, Storage I
and Retrieval of information using PUSH and
POP instructions, Subroutine, Information Ch. 9 & Pg No.295-315
exchange between Program Counter and Stack
pointer
16 Conditional CALL and RET instructions, I
Subroutines: multiple calling, nesting and
common ending.
Ch. 9 & Pg No.315-318
Similarities and Differences between PUSH/POP
and
CALL/RET instructions.

|Page 2
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

 Course Description (As per course Specification)


This course introduces microprocessors, instruction set of microprocessors, assembly
language programming and machine language concepts. Internal communication
structure, memory interface components, Input Output processors, Direct Memory
Access technique are discussed. The role of interrupts and interrupt handling
techniques are also introduced. The students are given training in developing
assembly language programs for simple problems during the theoretical and practical
sessions

 Course Learning Outcomes (As per syllabus)


 Define fundamental concepts of 8085 microprocessor
 Recognize the applicability of microprocessors
 List and describe 8085 instruction set
 Develop Assembly Language Programs using 8085 Instruction Set
 Analyse Assembly Language programs for proposing solutions to the real
world problems
 Operate to solve problems, manage time, resources and tasks with group
members.
 Express understood concepts in both oral and written ways.

 Lab Description
 This lab session is designed to establish a foundation for understanding the
basic Assembly Language Instruction and incorporate Assembly Language
Programming using 8085 Simulator. The experiments are designed to provide
a substantial and motivational lab experience.
 The 8085 Simulator studied programs include:
Program to perform Arithmetic operation using direct addressing and register
Instruction for Flags, Jump Instruction, CMP Instruction, 16 Bit Addition and
Subtraction, finding Largest, Smallest number in an array, Sorting, Conversion
like BCD to HEX, HEX to BCD, HEX to ASCII, ASCII to HEX
Square of a Number Using Look up Table

|Page 3
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Hardware / Software Requirements


 Hardware: Personal Computer with Windows 7 OS.
 Software : 8085 Simulator 2.0

Marks Distribution with assessment criteria


S. No Assessment Week Due Marks
1 Assignment-1 4 2
2 Assignment-2 8 2
3 Quiz-1 5 3
4 Quiz-2 9 3
5 Lab Final Exam 15 10
Total Marks 20

Instructions for assessment methods:


1. Quizzes : Online or Lab Quizzes
2. Assignments: Online or Hard Copy Submission
3. Lab Final Exam : Students has to write Assembly Language program and
show the Output in the System

|Page 4
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Week-wise Practical Schedule (15 weeks)


Week Lab/ Title of the Experiment Page
Exercise # / Exercise No.
1 1 Microprocessor 8085 organization 5 to 10
(SIMULATOR 8085 COMPILER)

2 2 Instruction classifications and examples 11 to 13

3 3 Data transfer instructions and simple 14 to 19


programs(add two 8 bit numbers , subtraction
of two 8 bit numbers using direct addressing
and registers)

4 4 Programs multiplication and division of 8 bit 20 to 22


numbers

5 5 Instructions for flags, use carry flag in Addition 23 to 26


and use borrow in subtraction

6 6 Jump instructions; Find the Greatest of two 27 to 28


Number using CMP Instruction.

7 7 16 bit addition and subtraction , use of DAD 29 to 32


and SHLD instructions

8 8 Find largest number in an array of data. Find 33 to 35


smallest number in an array of data.

9 9 Arrange an array of data in ascending order. 36 to 38


Arrange an array of data in Descending order.

10 10 BCD to HEX conversion, HEX to BCD 39 to 42


conversion

11 11 HEX to ASCII conversion 43 to 45

12 12 ASCII to HEX conversion 46

13 13 Square of a number using look up table. 47 to 48

14 14 Revision

|Page 5
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

15 15 Final Lab Exam

Lab Session 1 / Exercise 1 (Week 1)

Microprocessor 8085 Organization (SIMULATOR 8085


COMPILER)
 Objectives / Statement Purpose:
To Study the Microprocessor 8085 and the Installation of 8085 Simulator
 Activity Outcomes:
Student should get familiar with the Architecture of 8085 Microprocessor and the
installation of 8085 Simulator,

 Instructions for solving problems :


Architecture of 8085 Microprocessor
a) General purpose registers
It is an 8 bit register i.e. B, C, D, E, H, L. The combination of 8 bit register is
known as register pair, which can hold 16 bit data. The HL pair is used to act as
memory pointer is accessible to program.

b) Accumulator
It is an 8 bit register which hold one of the data to be processed by ALU and
stored the result of the operation.
c) Program counter (PC)
It is a 16 bit pointer which maintain the address of a byte entered to line stack.
d) Stack pointer (SP)
It is a 16 bit special purpose register which is used to hold line memory
address for line next instruction to be executed.

e) Arithmetic and logical unit


It carries out arithmetic and logical operation by 8 bit address it uses the
accumulator content as input the ALU result is stored back into accumulator.

f) Temporary register
It is an 8 bit register associated with ALU hold data, entering an operation,
used by the microprocessor and not accessible to programs.

g) Flags
Flag register is a group of fire, individual flip flops line content of line flag
register will change after execution of arithmetic and logic operation. The line states
flags are
i) Carry flag (C)
ii) Parity flag (P)
iii) Zero flag (Z)
iv) Auxiliary carry flag (AC)

|Page 6
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

v) Sign flag (S)


h) Timing and control unit
Synchronous all microprocessor, operation with the clock and generator and
control signal from it necessary to communicate between controller and peripherals.

i) Instruction register and decoder


Instruction is fetched from line memory and stored in line instruction register decoder
the stored information.

j) Register Array
These are used to store 8 bit data during execution of some instruction.

INSTALLATION STEPS FOR 8085 simulink

Step 1: Insert CD and Double Click autorun.

Step 2: Choose 8085 VIJAY.

Step 3: Press Next

|Page 7
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Step 4: Press Next

Step 5: Press Next

Step 6: Press Next

|Page 8
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Step 7: Press Next

Step 8: Press Install

Step 9: Press Finish

Step 10: Installation is complete and the 8085 Simulator is ready.

|Page 9
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

 Exercises (To be solved in Classroom):


 Task 1: Install 8085 Simulator in your System in Lab.
 Task 2: Write a sequence of instructions that will load 0FH in C register and
transfer the byte to a memory location whose address is 2051H.
PROGRAM:
MVI H, 20H
MVI L, 51H
MVI C, 0FH
MOV M,C
HLT
SOLUTION:

 Task 3: Write Simple Assembly Language program using MOV, MVI,


MOV M, r and MOV r, M Command to store data in Different Memory
Location and Register and see the value in Memory Dump, Register, PC of
8085 Simulator using stepinfo operation.

|Page 10
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

SOLUTION:

 Exercises for practice at home(Assignment):


Exercise 1: Try to Install Simulator 2.0 in your Home PC or Laptop.
Exercise 2: Try to write Simple Assembly Language program to store in Registers
A=01H, B=02H, C=03H, D=04H, E=05H, H=06H, L =07H, in memory Location
1000H = 08H and see how the Data will be stored in different Registers and memory
Location, the changes in PC using step info operation.

|Page 11
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Lab Session 2 / Exercise 2 (Week 2)

Instruction Classification and examples


 Objectives / Statement Purpose:
To understand the 8085 Instruction set Classification.
 Activity Outcomes:
Student should get familiar with the Classification of 8085 Microprocessor
instruction based on size, based on type of operation and the Addressing Modes.

 Instructions for solving problems :


The microprocessor instructions are classified
a. based on word size/ format of instructions as.
1. One byte instructions ‐ 8‐bit length.
2. Two byte instructions ‐ 16‐bit length.
3. Three byte instructions ‐ 24‐bit length.

b. based on type of operation performed by the instruction as.


1. Data transfer instructions.
2. Arithmetic instructions.
3. Logic instructions.
4. Branching instructions.
5. Machine control instructions.

c. Addressing Modes: Different Addressing modes are Immediate Addressing, Direct


Addressing
Register Addressing, Register Indirect Addressing, Implied Addressing

1) Immediate Addressing:
In immediate addressing mode, the data is specified in the instruction itself.
The data will be a part of the program instruction.
EXAMPLE: MVI B, 3EH - Move the data 3EH given in the instruction to B
register;

2) Direct Addressing:
In direct addressing mode, the address of the data is specified in the
instruction. The data will be in memory. In this addressing mode, the program
instructions and data can be stored in different memory.
EXAMPLE: LDA 1050H - Load the data available in memory location
1050H in to accumulator;

3) Register Addressing:
In register addressing mode, the instruction specifies the name of the register
in which the data is available.

|Page 12
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

EXAMPLE: MOV A, B - Move the content of B register to A register;

4) Register Indirect Addressing:


In register indirect addressing mode, the instruction specifies the name of the
register in which the address of the data is available. Here the data will be in memory
and the address will be in the register pair.
EXAMPLE: MOV A, M - The memory data addressed by H L pair is moved
to A register.

5) Implied Addressing:
In implied addressing mode, the instruction itself specifies the data to be
operated.
EXAMPLE: CMA - Complement the content of accumulator

 Exercises (To be solved in Classroom):


 Task 1: Write Assembly Language Program to complement a given number
using Implied Addressing.
 OUTPUT :
BINARY VALUE OF 2 = 0000 0010
1’S COMPLEMENT OF 2 = 1111 1101
= F DH

 Task 2: Write Assembly Language Program to find the 2’s Complement of a


given number and store the answer in Memory Location 1000H.
Hint

|Page 13
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

2’s Complement = 1’s Complement + 1


STA  Used to move the content of accumulator to memory Location
 Task 3: Write Assembly Language Program to Load the HL pair with
2000H, BC Pair with 3000H and DE pair with 4000H.
Hint
LXI Rp,16 bit data Load the Register Pair Immediately
 Task 4: Write Assembly Language Program to understand different
Addressing Modes.
 Exercises for practice at home(Assignment):
Exercise 1: With and without using LXI command how you will transfer one byte
from memory location whose address is 2450 H to another memory location whose
address is 2550H.

|Page 14
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Lab Session 3 / Exercise 3 (Week 3)

Data Transfer Instruction and Simple Programs.


(Add two 8 Bit numbers, Subtraction of two 8 bit
numbers using direct addressing and registers)

 Objectives / Statement Purpose:


To understand the 8085 Data Transfer Instruction, to perform 8 Bit addition and
Subtraction.
 Activity Outcomes:
Student should get familiar with the Data Transfer Instruction of 8085 and
Arithmetic Operations like Addition and Subtraction using Assembly Language
Program.

 Instructions for solving problems :


DATA TRANSFER INSTRUCTIONS.
Data transfer instructions copy data from a source into a destination without
modifying the content of the source.

The source and destinations can be registers, memory locations or accumulator

EXAMPLES
a. Move between Register and Register-MOV Rd, Rs
b. Move Immediate Instruction- MVI Rd, 8 bit data
c. Move between Register and Memory- MOV M , r and MOV r, M
d. Load Immediate Register Pair- LXI Rp,16 bit data
e. Store Accumulator Direct- STA addr
f. Load Accumulator Direct- LDA addr

ARITHMETIC INSTRUCTIONS
a) ADD with register/memory
ADD r [or] ADD M
r  register name M  memory location
It is used to add the contents of a specified register or memory to the contents
of the accumulator.
(A)  (A) + r.
The result is stored in the accumulator.

b) ADD immediate.
|Page 15
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

ADI 8 bit data


It is used to add 8 bit data to the contents of the accumulator.
(A)  (A) + 8-bit data.
The result is stored in the accumulator.

c) ADD with carry


ADC r [or] ADC M
It is used to add the contents of a specified register or memory along with the
carry flag to the contents of the accumulator.
(A)  (A) + r + Carry
The result is stored in the accumulator.

d) SUB with register/memory


SUB r [or] SUB M
r  register name M  memory location
It is used to subtract the contents of a specified register or memory from the
contents of the accumulator.
(A)  (A) - r.
The result is stored in the accumulator

e) SUB immediate.
SUI 8 bit data
It is used to subtract 8 bit data from the contents of the accumulator.
(A)  (A) - 8-bit data.
The result is stored in the accumulator

f) SUB immediate with borrow.


SBI 8 bit data
It is used to subtract 8 bit data from the contents of the accumulator.
(A) (A) - 8-bit data - carry.
The result is stored in the accumulator.

 Exercises (To be solved in Classroom):


 Task 1: Write Assembly Language Program to perform Simple Addition of
two 8 Bit Numbers.
 ALGORITHM:
1) Start the program by Loading the First 8 Bit Data in Accumulator
2) Move the Data to Register B
3) Get the Second Data in a Memory Location
4) Move the Second 8 Bit Data from Memory to the Accumulator
5) Add Accumulator and Register B Content
6) Store the Accumulator Content( Result) in a Specified Memory Location

|Page 16
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

OUTPUT :

INPUT Memory Equivalent Data Data Converted


Address in Memory
Program Dump (In Decimal) (In
HexaDecimal

1050 041A 05 05

1051 041B 12 0C

OUTPUT 1052 041C 17 11

SCREEN SHOT TO RUN THE PROGRAM


Step 1: Type and Save your Program

Step 2: Press Debug Compile as follow

Step 3: Enter Input Data as follow


a) Go to Memory Dump 041A then double click and enter First Data (Here as 5).

b) Go to Memory Dump 041B then double click and enter Second Data (Here as 12).

|Page 17
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

c) You can Notice 12 has been changed to 0e (because Decimal Number 12 has
been converted to Hexadecimal 0e)

Step 4: Press Debug Run

Step 5: Press OK

|Page 18
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Step 6: See the Output in the Specified Memory Dump as follow

Output = 11

 Task 2: Write Assembly Language Program to perform Simple Subtraction


of two 8 Bit Numbers.
ALGORITHM:
1) Start the program by Loading the First 8 Bit Data in Accumulator
2) Move the Data to Register B
3) Get the Second 8 Bit Data in a Memory Location
4) Move the Second Data from Memory to the Accumulator
5) Subtract Register B Content from the Accumulator
6) Store the Accumulator Content( Result) in a Specified Memory Location

OUTPUT :
Here B= 5, A = 12
So A-B12-5 =7

|Page 19
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

INPUT Memory Equivalent Data Data Converted


Address in Memory
Program Dump (In Decimal) (In
HexaDecimal

1050 041A 05 05

1051 041B 12 0C

OUTPUT 1052 041C 7 7

 Exercises for practice at home(Assignment):


Exercise 1: Write Assembly Language Program to add any 3 numbers.
Exercise 2: Write Assembly Language Program to evaluate the expression a + b –c

|Page 20
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Lab Session 4 / Exercise 4 (Week 4)

Program Multiplication and Division of 8 Bit Numbers


.
 Objectives / Statement Purpose:
To perform 8 Bit Multiplication and Division.
 Activity Outcomes:
Student should get familiar with Arithmetic Operations like Multiplication and
Division using Assembly Language Program.

 Instructions for solving problems :


Go through the Instruction Used in Lab Session 3
a) Increment Register or Memory
INR r or INR M
This instruction increments the contents of the specified register or memory
location, M by 1.
The result is stored in the specified register itself.
Example: 1
INR C Increments the content of C register by 1 and the new value is stored
in C register.

b) Decrement Register or Memory

DCR r or DCR M

This instruction decrements the contents of the specified register or memory


location, M by 1.
The result is stored in the specified register or memory location itself.

Example: 1
DCR C  Decrements the content of C register by 1 and the new value is
stored in C register.

c) Increment Register Pair

INX rp
This instruction increments the contents of the specified register pair by 1.
(rp)  (rp) +1
The register pair used are BC, DE, HL and the 16-bit Stack Pointer.
The result is stored in the specified register pair itself.

|Page 21
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

 Exercises (To be solved in Classroom):


 Task 1: Write Assembly Language Program to perform Multiplication of
two 8 Bit Numbers.
ALGORITHM:
1) Initialize Accumulator(Answer) and Register D(Carry) as 0
2) Load HL Register with address of memory location,Move the data to
Register B
3) Get the second data and load it to Register C
4) Add Register B Content with accumulator
5) Check for carry, If no Carry do Step 7
6) Increment the value of carry, Decrement Register C Content
7) Check whether repeated addition is over
8) Store the value of product and carry in memory location

OUTPUT :
INPUT Memory Equivalent Data (In Data Converted
Address in Memory Decimal)
Program Dump (In
HexaDecimal

1050 1050 04 04

1051 1051 02 02

OUTPUT 1052 041c 08 8

1053 041d 0

INPUT Memory Equivalent Data Data Converted


Address in Memory
Program Dump (In Decimal) (In
HexaDecimal

1050 1050 10 oa

1051 1051 30 10

OUTPUT 1052 041c 300 2c

1053 041d 1

|Page 22
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

 Task 2: Write Assembly Language Program to perform Division of two 8


Bit Numbers.
ALGORITHM:
1) Load HL Register with address of memory location, Move the data to
Register B(Divisor)
2) Initialize Register C as 0 (Quotient)
3) Compare B with A (A-B) if it is minus do step 7
4) Subtract B from A
5) Increment C Register
6) Do Step 3
7) Store the value of Quotient from C and Remainder from A

OUTPUT :
INPUT Memory Equivalent Data (In Data Converted(In
Address in Memory Decimal) HexaDecimal
Program Dump

4150 1036 02 02

4151 1037 07 07

OUTPUT 4152 1038 01 01

4151 1039 03 03

INPUT Memory Equivalent Data (In Data Converted(In


Address in Memory Decimal) HexaDecimal
Program Dump

1050 1036 03 03

1051 1037 15 0f

OUTPUT 1052 1038 00

1053 1039 05

 Exercises for practice at home(Assignment):


Exercise 1: Write Assembly Language Program to evaluate the expression
3*3*3
Exercise 2: Write Assembly Language Program to evaluate the expression
20 / 2

|Page 23
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Lab Session 5 / Exercise 5 (Week 5)

Instruction for Flags, Use Carry Flag in Addition and use borrow
in Subtraction.
.
 Objectives / Statement Purpose:
To perform 8 Bit Addition using Carry and 8 Bit Subtraction with Borrow.
 Activity Outcomes:
Student should get familiar with Arithmetic Operations like Addition with Carry
and Subtraction with Borrow.

 Instructions for solving problems :


a) Jump unconditionally
JMP 16-bit address
The program sequence is transferred to the memory location specified by the 16-bit
address given in the operand.
Example: JMP 2034H.
NB: In 8085 JMP unconditionally ins. is used to do the function of GOTO

b) Jump conditionally Operand: 16-bit address

The program sequence is transferred to the memory location specified by the


16-bit address given in the operand based on the specified flag of the PSW as
described

Opcode Description Flag Status


JC Jump on Carry CY = 1
JNC Jump on no Carry CY = 0
JP Jump on positive S=0
JM Jump on minus S=1
JZ Jump on zero Z=1
JNZ Jump on no zero Z=0
JPE Jump on parity even P=1
JPO Jump on parity odd P=0

|Page 24
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

 Exercises (To be solved in Classroom):


 Task 1: Write Assembly Language Program to perform Addition of two 8
Bit Numbers using Carry.
ALGORITHM:
1) Start the Program by Loading the first data into Accumulator
2) Move the data to B Register
3) Get the Second Data and Load into Accumulator
4) Add the Accumulator and Register B Content
5) If No Carry Do Step 7
6) Increment Register C (Carry is there)
7) Store the Accumulator Content( Result) to Memory Location specified
8) Move the Register C(Carry) to Accumulator.
9) Store the Accumulator(Carry) to Memory Location specified by HL Pair

OUTPUT :
Here A = 24010 = FO16
B = 4910 = 3116
A+B = 28910 = 12116

INPUT Memory Equivalent Data Given Data Converted


Address in Memory
Program Dump (In Decimal) (In
HexaDecimal

1000 0802 240 F0

1001 0803 49 31

OUTPUT 1002 0804 289 21(Answer)

1003 0805 1(Carry)

|Page 25
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

(or)

ALGORITHM:
1) Load HL Register with Memory Address 1000
2) Move the First Data From Memory to Accumulator
3) Increment HL Pair
4) Move the Second Data From Memory to Register B
5) Load Register C as 0 for Carry
6) Add the Accumulator and Register B Content
7) If No Carry Do Step 9
8) Increment Register C (Carry is there)
9) Increment HL Pair
10) Move the Accumulator Content( Result) to Memory Location specified by
HL Pair
11) Increment HL Pair
12) Move the Register C( Carry) to Memory Location specified by HL Pair

OUTPUT :
Here A = 24010 = FO16
B = 4910 = 3116
A+B = 28910 = 12116

INPUT Memory Equivalent Data Given Data Converted


Address in Memory
Program Dump (In Decimal) (In
HexaDecimal

1000 1000 240 F0

1001 1001 49 31

OUTPUT 1002 1002 289 21(Answer)

1003 1003 1(Carry)

Task 2: Write Assembly Language Program to perform Subtraction of two 8 Bit


Numbers using Borrow
AIM: To Perform Subtraction of Two 8 Bit Numbers using Borrow.
ALGORITHM:
1) Move 0 to Register C for Carry
2) Load the first data into Accumulator, Move the data to B Register
3) Get the Second Data and Load into Accumulator
4) Subtract the Register B Content From the Accumulator
5) If Positive Do Step 8
6) Find the twos Complement of the Accumulator
7) Store the Accumulator Content( Result) to Memory Location specified

|Page 26
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

8) Move the Register C (Carry) to Accumulator.


9) Store the Accumulator(Carry) to Memory Location specified by HL Pair

OUTPUT :
Here B = 1710 = 1116 A = 0310 = 0316 A-B = 0310-1710 = - 1410
Here the Answer is Negative so find 2’s Complement of 14  0000 1110
1’s Complement of 14  1111 0001
+1 1
2’s Complement of 14  1111 0010 F216

INPUT Memory Equivalent Data Data Converted


Address in Memory
Program Dump (In Decimal) (In HexaDecimal

1000 0802 17(B) 11

1001 0803 3(A) 3

OUTPUT 1002 0804 14 F2 (Answer)

1003 0805

INPUT Memory Equivalent Data Data Converted


Address in Memory
Program Dump (In Decimal) (In HexaDecimal

INPUT 1000 0802 3(B) 3

1001 0803 17(A) 11

OUTPUT 1002 0804 14 0e (Answer)

1003 0805

 Exercises for practice at home(Assignment):


Exercise 1: Practice Addition with Carry with different numbers and check the
answers manually
Exercise 2: Practice Subtraction with borrow with different numbers and check the
answers manually.

|Page 27
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Lab Session 6 / Exercise 6 (Week 6)

Jump Instructions. Find the Greatest of two number using CMP


instructions.
.
 Objectives / Statement Purpose:
To find the greatest of two numbers using CMP instructions..
 Activity Outcomes:
Student should get familiar with CMP Instruction and find the greatest of two
Numbers.

 Instructions for solving problems :


Go through the Instruction Used in Lab Session 5
CMP register: This instruction compares the content of the accumulator with the
value in register given in instruction.

Example
CMP B
If (B) > (A) , then Carry flag is set
If (B) = (A) , then Zero flag is set
If (A) > (B) , then No flag is set

 Exercises (To be solved in Classroom):


 Task 1: Write Assembly Language Program to find the greatest of two
numbers using CMP Instruction.
ALGORITHM:
1) Load the HL Pair with address 3000H
2) Move the 1st operand from memory to Reg A
3) Increment HL Pair
4) Move the 2nd operand from memory to Reg B
5) Compare B with A
6) Jump to Step 8 if there is no carry
7) Move the Largest from Reg B to Reg A
8) Increment HL Pair
9) Move the Result from Reg A to Memory

|Page 28
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

OUTPUT :

INPUT Memory Equivalent Data Data Converted


Address in Memory
Program Dump (In Decimal) (In HexaDecimal

1000 1000 04 04

1001 1001 08 08

OUTPUT 1002 1002 08 08(Largest)

INPUT Memory Equivalent Data Data Converted


Address in Memory
Program Dump (In Decimal) (In
HexaDecimal

INPUT 1000 1000 15 0f

1001 1001 10 0a

OUTPUT 1002 1002 15 0f(Largest)

 Exercises for practice at home(Assignment):


Exercise 1: Write Assembly Language Program to find the greatest of three
numbers using CMP Instruction.

|Page 29
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Lab Session 7 / Exercise 7 (Week 7)

16 Bit addition and Subtraction use of DAD and SHLD


Instructions.
.
 Objectives / Statement Purpose:
To perform 16 Bit Addition and Subtraction using DAD and SHLD Command.
 Activity Outcomes:
Student should get familiar with 16 Bit addition and subtraction, use of DAD and
SHLD Instruction.

 Instructions for solving problems :


a) Double Register Add
DAD register pair

It is used to add the contents of HL pair with the contents of register pair mentioned in
the instruction. (HL)  (HL) + (register pair).
The result is stored in the accumulator.

Example: 1
DAD B

Adds the content of the HL register with the content of the BC register pair stores the
result in the HL register pair

HL  HL+BC

SHLD (store H and L register direct): The contents of register L are stored into
the memory location specified by the 16-bit address in the operand and the
contents of H register are stored into the next memory location by incrementing
the operand. The contents of registers HL are not altered. This is a 3-byte
instruction, the second byte specifies the low-order address and the third byte
specifies the high-order address.
Example: SHLD 2470

|Page 30
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

 Exercises (To be solved in Classroom):


 Task 1: Write Assembly Language Program to perform addition of two 16
Bit numbers using DAD and SHLD Command.
ALGORITHM:
1) Get the Higher Order Bit of first 16-Bit Numbers in A and Move to Register D
2) Get the Lower Order Bit of first 16-Bit Numbers in A and Move to Register E
3) Get the Higher Order Bit of Second 16-Bit Numbers in A and Move to
Register H
4) Get the Lower Order Bit of Second 16-Bit Numbers in A and Move to
Register L
5) Add DE and HL Register pairs Content.
6) Store 16 Bit Result in Memory Locations 1004 and 1005 H

OUTPUT :

INPUT Memory Equivalent Data Data Converted


Address in Memory
Program Dump (In Decimal) (In
HexaDecimal

1000 1000 02 02

1001 1001 03 03

1002 1002 04 04

1003 1003 05 05

OUTPUT 1004 1004 08 08

1005 1005 06 06

 Task 2: Write Assembly Language Program to perform subtraction of two


16 Bit numbers using DAD and SHLD Command.
ALGORITHM:
1) Get the Higher Order Bit of first 16-Bit Numbers in A and Move to Register D
2) Get the Lower Order Bit of first 16-Bit Numbers in A and Move to Register E
3) Get the Higher Order Bit of Second 16-Bit Numbers in A and Move to
Register H
4) Get the Lower Order Bit of Second 16-Bit Numbers in A and Move to
Register L
5) Move E Register Content to Accumulator
6) Subtract L From A

|Page 31
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

7) Move D Register Content to Accumulator


8) Subtract H From A
9) Store the Result in 1004 and 1005

OUTPUT :
INPUT Memory Equivalent Data Data Converted
Address in Memory
Program Dump (In Decimal) (In
HexaDecimal

1000 1000 05 05

1001 1001 09 09

1002 1002 03 03

1003 1003 06 06

OUTPUT 1004 1004 03 03

1005 1005 02 02

(Or)

ALGORITHM:
1) Get the Higher Order Bit of first 16-Bit Numbers in A and Move to Register D
2) Get the Lower Order Bit of first 16-Bit Numbers in A and Move to Register E
3) Get the Higher Order Bit of Second 16-Bit Numbers in A and Move to
Register H
4) Get the Lower Order Bit of Second 16-Bit Numbers in A and Move to
Register L
5) Move E Register Content to Accumulator
6) Subtract L From A
7) Move D Register Content to Accumulator
8) Subtract H From A
9) Store the Result in 1004 using SHLD Command

OUTPUT :

INPUT Memory Equivalent Data Data Converted


Address in Memory
Program Dump (In Decimal) (In HexaDecimal

1000 1000 05 05

|Page 32
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

1001 1001 09 09

1002 1002 03 03

1003 1003 06 06

OUTPUT 1004 1004 03 03

1005 1005 02 02

 Exercises for practice at home(Assignment):


Exercise 1: Write Assembly Language Program to add three 16 Bit numbers

|Page 33
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Lab Session 8 / Exercise 8 (Week 8)

Find largest number in array of data, Find smallest number in an


array of data.
 Objectives / Statement Purpose:
To find the largest number in an array and smallest number in an array
 Activity Outcomes:
Student should get familiar with Array and finding smallest , greatest number in
an array.

 Instructions for solving problems :


Go through the Instruction for Data Transfer, Jump, Loop, CMP
given in previous Lab Session.
 Exercises (To be solved in Classroom):
 Task 1: Write Assembly Language Program to find the largest number in an
array.
ALGORITHM:
1) Load the address of the Size of Array in HL Register Pair, Move it to B
Register(Array Size)
2) Increment HL pair, Get the first element in Accumulator
3) Decrement the size B Register
4) Increment HL pair
5) Compare M with Accumulator Content, If Positive Go to Step 7
6) Move Memory Content to Accumulator
7) Decrement B
8) Jump if not Zero to Step 4
9) Store the Largest Element from the Accumulator to the Specified Memory
address.

|Page 34
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

OUTPUT :

INPUT Memory Equivalent Data Data Converted


Address in Memory Dump
Program (In (In HexaDecimal
Decimal)

1000 1000 7 07

1001 1001 12 0c

1002 1002 35 23

1003 1003 60 3c

1004 1004 10 0a

1005 1005 2 2

1006 1006 5 5

1007 1007 22 16

OUTPUT 1050 1050 60 3c(Largest


Number)

|Page 35
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

 Task 2: Write Assembly Language Program to find the largest number in an


array.
ALGORITHM:
1) Load the address of the Size of Array in HL Register Pair,Move it to B
Register(Array Size)
2) Increment HL pair, Get the first element in Accumulator
3) Decrement the size B Register
4) Increment HL pair
5) Compare M with Accumulator Content, If Minus Go to Step 7
6) Move Memory Content to Accumulator
7) Decrement B
8) Jump if not Zero to Step 4
9) Store the Largest Element From the Accumulator to the Specified Memory
address.

OUTPUT :
INPUT Memory Equivalent Data Data Converted
Address in Memory
Program Dump (In Decimal) (In HexaDecimal

1000 1000 7 07

1001 1001 12 0c

1002 1002 35 23

1003 1003 60 3c

1004 1004 10 0a

1005 1005 2 2

1006 1006 5 5

1007 1007 22 16

OUTPUT 1050 1050 2 02(Smallest


Number)

 Exercises for practice at home(Assignment):


Exercise 1: Write Assembly Language Program to find the smallest and greatest
number in an array, Store the smallest number in Location 2000H and greatest in
2001H.

|Page 36
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Lab Session 9 / Exercise 9 (Week 9)

Arrange an array of data in ascending order. Arrange an array of


data in Descending Order.
 Objectives / Statement Purpose:
To sort an array of data in ascending and descending order.
 Activity Outcomes:
Student should get familiar with Array and sorting an array of data in Ascending
and Descending order.

 Instructions for solving problems :


a) Decrement Register pair
DCX rp
This instruction decrements the contents of the specified register pair by 1.
(rp)  (rp) -1
The register pair used are BC, DE, HL and the 16-bit Stack Pointer.
The result is stored in the specified register pair itself.
Example: 1
DCX D
If the initial value in DE register pair is 1500H, then the instruction DCX D
decrements 16 bit value in DE register pair by 1 and the new value is stored in DE.

 Exercises (To be solved in Classroom):


 Task 1: Write Assembly Language Program to arrange an array of Data in
ascending order.
ALGORITHM:
1) Load the address of the Size of Array in HL Register Pair,Move it to C
Register(Array Size)
2) Copy it in D register (For Bubble Sort(N-1) Times
3) Get the First data in A Register
4) Compare it with the value at next location
5) If they are out of order, Swap the Content of A register and memory
6) Decrement D register Content by 1
7) Repeat Steps 4 to 6 till the value in De Register become zero

|Page 37
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

8) Decrement C register content by 1


9) Repeat steps 2 to 8 till the value in C register becomes zero.

OUTPUT :

Memory Equivalent Data Data Converted


Address in Memory
Program Dump (In Decimal) (In
HexaDecimal

1000 1000 05 05
INPUT
1001 1001 04 04

1002 1002 02 02

1003 1003 09 09

1004 1004 12 0C

1005 1005 06 06

1000 1000 05 05

1001 1001 02 02

1002 1002 04 04
OUTPUT
1003 1003 06 06

1004 1004 09 09

1005 1005 12 0C

 Task 2: Write Assembly Language Program to arrange an array of Data in


descending order.

ALGORITHM:
1) Load the address of the Size of Array in HL Register Pair,Move it to C
Register(Array Size)
2) Copy it in D register (For Bubble Sort(N-1) Times
3) Get the First data in A Register
4) Compare it with the value at next location
5) If they are out of order, Swap the Content of A register and memory
6) Decrement D register Content by 1
7) Repeat Steps 4 to 6 till the value in De Register become zero
8) Decrement C register content by 1

|Page 38
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

9) Repeat steps 2 to 8 till the value in C register becomes zero.

OUTPUT :

Memory Equivalent Data Data


Address Memory Converted
in Dump (In
Program Decimal) (In
HexaDecimal

1000 1000 05 05
INPUT
1001 1001 04 04

1002 1002 02 02

1003 1003 09 09

1004 1004 12 0C

1005 1005 06 06

1000 1000 05 05

1001 1001 12 0C

1002 1002 09 09
OUTPUT
1003 1003 06 06

1004 1004 04 04

1005 1005 02 02

 Exercises for practice at home(Assignment):


Exercise 1: Write Assembly Language Program to sort an array of data in ascending
order. Store the sorted array from Location 2000H.

|Page 39
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Lab Session 10 / Exercise 10 (Week 10)

BCD to HEX Conversion, HEX to BCD Conversion


 Objectives / Statement Purpose:
To Convert Given BCD Number to Hexadecimal, Hexadecimal number to BCD.
 Activity Outcomes:
Student should get familiar with how the BCD Number will be represented and
converted to Hexa Decimal and Vice Versa.

 Instructions for solving problems :


a. AND instruction
1. ANA r
This instruction performs logical AND operation between the specified
register, r and the accumulator.
The result is stored in the accumulator.

Example: 1
ANA B
If A = 97H = 1001 0111
And if B = C5H = 1100 0101
Then ANA B results in A = 1000 0101= 85H
2. ANI 8-bit data
This instruction performs logical AND operation between the accumulator and
the 8 bit data given in the instruction itself.
The result is stored in the accumulator.

Example: 1
ANI 0FH
If A = 97H = 1001 0111
And if 8 bit data = 0FH = 0000 1111
Then ANI 0FH results in A = 0000 0111= 07H in the A register.
b. ROTATE instruction
1. Rotate accumulator right
RRC
Each binary bit of the accumulator is rotated right by one position. Bit D0 is
placed in the position of D7 as well as in the Carry flag. CY is modified
according to bit D0. S, Z, P,AC are not affected.
2. Rotate accumulator left
RLC

|Page 40
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Each binary bit of the accumulator is rotated left by one position. Bit D7 is
placed in the position of D0 as well as in the Carry flag. CY is modified
according to bit D7. S, Z, P, AC are not affected.
3. Rotate accumulator left through carry
RAL
Each binary bit of the accumulator is rotated left by one position through the
Carry flag. Bit D7 is placed in the Carry flag, and the Carry flag is placed in
the least significant position D0. CY is modified according to bit D7. S, Z, P,
AC are not affected.
4. Rotate accumulator right through carry
RAR
Each binary bit of the accumulator is rotated right by one position through the
Carry flag. Bit D0 is placed in the Carry flag, and the Carry flag is placed in
the most significant position D7. CY is modified according to bit D0. S, Z, P,
AC are not affected.

c. Decimal adjust accumulator


DAA none
The contents of the accumulator are changed from a binary value to two 4-bit
binary coded decimal (BCD) digits. This is the only instruction that uses the
auxiliary flag to perform the binary to BCD conversion, and the conversion
procedure is described below. S, Z, AC, P, CY flags are altered to reflect
the results of the operation.

If the value of the low-order 4-bits in the accumulator is greater than 9 or if


AC flag is set, the instruction adds 6 to the low-order four bits.
If the value of the high-order 4-bits in the accumulator is greater than 9 or if
the Carry flag is set, the instruction adds 6 to the high-order four bits.

Example: DAA

|Page 41
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

 Exercises (To be solved in Classroom):


 Task 1: Write Assembly Language Program to Convert BCD Number to
Hexa Decimal.
ALGORITHM:
1) Load the data 0fH to the accumulator.
2) Move the accumulator content to Register B.
3) Load the BCD Number in Location 1000, move it to C and A.
4) Perform AND B with Accumulator.
5) Do RRC (Rotate Accumulator Right)for 4 times then move it to Register D.
6) Load 0 to Accumulator.
7) Add 10 to Accumulator.
8) Decrement Register D Content.
9) Check if not zero then do step 7.
10) Add E to Accumulator.
11) Store the Hexadecimal Equivalent from Accumulator to Specified memory
Location.

INPUT:
BCD Number: 0010 0111
We need to enter its Hexa Decimal Equivalent as Input: (1X23) +(1X22) +(1X21)
+ (1X20)
= 32+4+2+1 =39 (Decimal)
Convert 39 to Hexadecimal = 27H

OUTPUT:
0010 0111
2 7
Decimal Number 27 = 1B Hexadecimal.

Memory Data Data Converted


Address in
Program (In Decimal) (In
INPUT
HexaDecimal

0500 240 f0H

1000 39 27H

OUTPUT 1001 27(Decimal) 1B(Hexa)

|Page 42
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

 Task 2: Write Assembly Language Program to Convert Hexa Decimal


number to BCD.

ALGORITHM:
1) Load the data 0fH to the accumulator.
2) Move the accumulator content to Register B.
3) Load the Hexa Decimal Number in Location 1000, move it to C and A.
4) Perform ANI (And Immediate) 0f with Accumulator.
5) Move Accumulator Content to E and C Register Content to A
6) Perform AND Operation with the Register B and Accumulator Content.
7) Do RRC (Rotate Accumulator Right) for 4 times then move it to Register D.
8) Check if zero then do step 14.
9) Move 0 to Accumulator
10) Add 16 to Accumulator
11) Convert it to Decimal Using DAA
12) Decrement D Register Content
13) Check if Non Zero then do step 10.
14) Add E to Accumulator.
15) Convert it to Decimal Using DAA
16) Increment the Memory address and move the BCD Equivalent from
Accumulator to that Memory Location.

OUTPUT :

Memory Data Data Converted


Address in
Program (In Decimal) (In
INPUT
HexaDecimal

0500 240 f0H

1000 27 1BH

1001 39(Decimal 27(Hexa)


OUTPUT Equivalent of
27)

a. Exercises for practice at home(Assignment):


Exercise 1: Practice the above two conversion with different Hexadecimal and
BCD Numbers.

|Page 43
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Lab Session 11 / Exercise 11 (Week 11)

HEX to ASCII Conversion.


 Objectives / Statement Purpose:
To Convert given Hexa Decimal number to ASCII number.
 Activity Outcomes:
Student should get familiar with how the ASCII Number will be represented and
how Hexa Decimal number will be converted to ASCII.

 Instructions for solving problems :


a. SUB immediate.
SUI 8 bit data
It is used to subtract 8 bit data from the contents of the accumulator.
(A) (A) - 8-bit data.
The result is stored in the accumulator.
Example: 1
SUI 03H
If the value of A = 05H then after the execution of the above instruction
the 8 bit data 03H is subtracted from the content of accumulator and the
result 02H is stored in the accumulator.
b. Compare Accumulator contents with immediate data
CPI 8-bit data
The 8-bit data is compared with the contents of the accumulator.
Example CPI 89H
if (A) < data: carry flag is set
if (A) = data: zero flag is set
if (A) > data: carry and zero flags are reset

|Page 44
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

|Page 45
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

 Exercises (To be solved in Classroom):


 Task 1: Write Assembly Language Program to Convert HEXA DECIMAL
to ASCII.
ALGORITHM:
1) Load the Hexa Decimal Number in Accumulator
2) Subtract 30 from the Accumulator
3) Compare the number with 0A
If number < 0A then jump to step 5. 3)
Subtract 07H with the number. 4)
5) Store the result in the accumulator

OUTPUT :

Memory Data Data Converted


Address
INPUT (In Decimal) (In Hexadecimal)
in
Program

0500 66 42(Hex)

OUTPUT 0501 0B(ASCII)

 Exercises for practice at home(Assignment):


Exercise 1: Write assembly language program to convert BCD to ASCII
Exercise 1: Write assembly language program to convert Binary to ASCII

|Page 46
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Lab Session 12 / Exercise 12 (Week 12)

ASCII to HEX Conversion.


 Objectives / Statement Purpose:
To Convert given ASCII number to Hexa Decimal number.
 Activity Outcomes:
Student should get familiar with how the ASCII Number will be represented and
how ASCII number will be converted to Hexa Decimal.

 Instructions for solving problems :


Go through the commands given in previous Lab
 Exercises (To be solved in Classroom):
 Task 1: Write Assembly Language Program to Convert ASCII to HEXA
DECIMAL.
ALGORITHM:
1) Load the Hexa Decimal Equivalent of an ASCII Code in Accumulator
2) Compare the number with 0A
3) If number < 0A then jump to step 5.
4) Add 07H with the number.
5) Add 30 H with the number.
6) Store the result in the accumulator

OUTPUT :

Memory Data Data Converted


Address
INPUT (In Decimal) (In HexaDecimal
in
Program

0500 11 0B

OUTPUT 0501 66 42(ASCII)

 Exercises for practice at home(Assignment):


Exercise 1: Write assembly language program to convert ASCII to Binary
Exercise 1: Write assembly language program to convert ASCII to BCD

|Page 47
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Lab Session 13 / Exercise 13 (Week 13)

Square of a Number using look up table.


 Objectives / Statement Purpose:
To Find the Square of a number using Look Up Table.
 Activity Outcomes:
Student should get familiar with Look up Table and how to use the Look up table
to find the square of a number.

 Instructions for solving problems :


A lookup table is an array that replaces runtime computation with a simpler array
indexing operation. The savings in terms of processing time can be significant, since
retrieving a value from memory is often faster than undergoing an 'expensive'
computation or input/output operation. The tables may be precalculated and stored in
static program storage, calculated (or "pre-fetched") as part of a program's
initialization phase (memorization), or even stored in hardware in application-specific
platforms. Lookup tables are also used extensively to validate input values by
matching against a list of valid (or invalid) items in an array and, in some
programming languages, may include pointer functions (or offsets to labels) to
process the matching input.
 Exercises (To be solved in Classroom):
 Task 1: Write Assembly Language Program to Convert ASCII to HEXA
DECIMAL.
ALGORITHM:
1) Load the Memory Location from 2060 to 2069 with the Square of numbers
0,1,2,3,4,5,6,7,8,9
2) Load the accumulator with the Input from Location 2050H
3) Add 60 to the Accumulator
4) Move the Accumulator content as Lower Order Address in Location L
Register
5) Move Immediately 20 as Higher Order Address in Location H Register.
6) Move the Memory Content to Accumulator
7) Store the Square of the number from Accumulator to Memory Location 2051.

OUTPUT :

|Page 48
King Khalid University Lab Manual
College of Computer Science Microprocessor & Assembly Language
Computer Science Program 343CSM -3

Memory Data Data Converted


INPUT
Address in
Program (In Decimal) (In
HexaDecimal

2050 05 05

2060 00 00

2061 01 01

2062 04 04

2063 09 09
LOOK 2064 16 10
UP
TABLE 2065 25 19

2066 36 24

2067 49 31

2068 64 40

2069 81 51

OUTPUT 2051 25 19

 Exercises for practice at home(Assignment):


Exercise 1: Find out Square Root of 0, 1, 4, 9, 16, 25, 36, 49, 64 and 81 Using
Look Up Table

|Page 49

You might also like