Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
325 views

Lab Manual For Assembly Language Course

The document provides details about experiments related to microprocessors. It discusses 15 experiments including introduction to assembly language, architecture of Intel 8086 microprocessor, arithmetic operations, logic operations, loops, LCD and LED modes, microcontrollers, and PIC microcontroller software. The first experiment introduces number systems like binary, decimal, hexadecimal and differences between low-level and high-level languages. The second experiment discusses the architecture of 8086 microprocessor including registers, segments, and addressing modes.

Uploaded by

Zaid Masood Khan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
325 views

Lab Manual For Assembly Language Course

The document provides details about experiments related to microprocessors. It discusses 15 experiments including introduction to assembly language, architecture of Intel 8086 microprocessor, arithmetic operations, logic operations, loops, LCD and LED modes, microcontrollers, and PIC microcontroller software. The first experiment introduces number systems like binary, decimal, hexadecimal and differences between low-level and high-level languages. The second experiment discusses the architecture of 8086 microprocessor including registers, segments, and addressing modes.

Uploaded by

Zaid Masood Khan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 42

List of Experiments

Microprocessor based system

Sr.No Experiments Name


01 Introduction to Assembly language and Number system

02 Introduction to Architecture of Intel 8086 Microprocessor.

03 The brief understanding of all the features of emu8086 software.

04 To understand the assembly instructions for arithmetic operations.


05 Add, Multiplication, Push/Pop instruction

06 To understand Addition, subtraction and compare instruction

07 To briefly understand the signed and unsigned multiplication and division instruction
process in assembly language

08 To study and understand the Assembly Language Instructions for Basic Logic
Operations
09 To understand how jump work in assembly Language Instructions and how to make if
else , switch and loop through jump instruction

10 To study and understand the functionality of all five loop instructions and their
implementation in different scenarios.

11 To Study The 80386 LCD Mode

12 To Study The LED Lamp Mode

13 Introduction To Microcontroller

14 To Study 8051 Microcontroller Using The Keil Software and Create Hex File

15 To Implement the IC Burning

16 To Implement the Micro C Software For PIC Microcontroller


Experiment No.1
Objective:
Introduction to differentiate between binary, decimal and hexadecimal number
system and also convert number in one number system to another number system. A
brief understanding of assembly language and understands the difference between low-
level and high-level languages.

Theory:
Most people today use decimal representation to count. In the decimal system
there are 10 digits: 0, 1, 3, 4, 5, 6, 7, 8, and 9. These digits can represent any value, for
example, 754. The value is formed by the sum of each digit, multiplied by the base (in
this it is 10 because there are 10 digits in decimal system) in power of digit position
(counting from zero):
2
7 * 10  5*101  4*10 0  700  50  4  754

Base Digit _ Position

Position of each digit is very important! For example if you place “7” at the end
value it will become another value.
2
5* 10  4*101  7 *10 0  500  40  7  547

Base Digit _ Position

Important note: any number power of zero is 1; even zero in power of zero is 1.

100  00  x 0  1

Computers are not as smart as humans are (or not yet), it’s easy to make an
electronic machine with two states on and off, or 1 and 0. Computers use binary system,
binary system uses 2 digits: 1, 1. and thus the base are 2. Each digit in a binary number is
called a BIT, 4 bits form a NIBBLE, 8 bits form a BYTE, two bytes form a WORD, and
two words form a DOUBLE WORD (rarely used).
High _ Bit nibble byte Low _ Bit

00010111 00010111 00010111 00010111

double _ word word

There is a convention to add “b” in the end of a binary number, this way we can
determine that 101b is a binary number with decimal value of 5. This binary number
10100101b equals to decimal value of 165:

10100101b
5
 1* 27  0* 26  1* 2  0* 2 4  0* 23  1* 2 2  0* 21  1* 2 0
 128  0  32  0  0  4  0  1
 165(decimal _ value)

Hexadecimal system uses 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9, A, B, C, D, E,


and F. and thus the base are 16. Hexadecimal numbers are compact and easy to read.

Decimal Binary Hexadecimal

(base 10) (base 2) (base 16)

0 0000 0

1 0001 1

2 0010 2

3 0011 3

4 0100 4

5 0101 5
6 0110 6

7 0111 7

8 1000 8

9 1001 9

10 1010 A

11 1011 B

12 1100 C

13 1101 D

14 1110 E

15 1111 F

Hexadecimal Value

1234

0001 0010 0011 0100

(binary numbers)

There is a convention to add “h” in the end of a hexadecimal number, this way we
can determine that 5Fh is a hexadecimal number with value of 95. We also add “0”
(zero) in the beginning of hexadecimal numbers that begin with a letter (A…F), for
example 0E120h.
The hexadecimal number 1234h is equal to decimal value 4660:

1234h
3
 1* 16  2*16 2  3*161  4*160  4660
Base Digit _ Position Decimal _ Value

Assembly languages are a type of low-level languages for programming


computers, microprocessors, microcontrollers, and other (usually) integrated circuits.
They implement a symbolic representation of the numeric machine codes and other
constants needed to program a particular CPU architecture.
This representation is usually defined by the hardware manufacturer, and is based
on abbreviations (called mnemonics) that help the programmer remember individual
instructions, registers, etc. An assembly language family is thus specific to certain
physical (or virtual) computer architecture. This is in contrast to most high-level
languages, which are (ideally) portable.
A utility program called assembler is used to translate assembly language
statements into the target computer’s machine code. The assembler performs a more or
less isomorphic translation (a one-to-one mapping) from mnemonic statements into
machine instructions and data. This is in contrast with high-level languages, in which a
single statement generally results in many machine instructions.
Assembly language is a low level programming language. You need to get some
knowledge about computer structure in order to understand anything.
The simple computer model is given below:

Random Access Memory

(RAM)

Central Processing Unit

(CPU)
Devices:

Display, Keyboard etc

The System Bus connects the various components of a computer. The CPU is the
heart of the computer, most of computations occurs inside the CPU. RAM is a place to
where the programs are loaded in order to be executed.

Conclusion:
Experiment No. 02
Introduction to 8086 Architecture
Objective:
Introduction to architecture of Intel 8086 Microprocessor.

Theory:
The 8086 had eight (more or less general) 16-bit registers including the stack
pointer, but excluding the instruction pointer, flag register and segment registers. Four of
them, AX, BX, CX, and DX, could also be accessed as twice as many 8-bit registers (see
figures) while the other four, BP, SI, DI and SP, were 16-bit only.

Central Processing Unit (CPU)

Most of the registers contain data/instruction offsets within 64 KB memory


segment. There are four different 64 KB segments for instructions, stack, data and extra
data. To specify where in 1 MB of processor uses four segment registers:
Code segment (CS) is a 16-bit register containing address of 64 KB segment with
processor instructions. The processor uses CS segment for all accesses to instructions
referenced by instruction pointer (IP) register. CS register cannot be changed directly.
The CS register is automatically updated during far jump, far call and far return
instructions.
Stack segment (SS) is a 16-bit register containing address of 64 KB segment
with program stack. By default, the processor assumes that all data referenced by the
stack pointer (SP) and base pointer (BP) registers is located in the stack segment. SS
register can be changed directly using POP instruction.
Data segment (DS) is a 16-bit register containing address of 64KB segment with
program data. By default, the processor assumes that all data referenced by general
registers (AX, BX, CX and DX) and index register (SI and DI) is located in the data
segment. DS register can be changed directly using POP and LDS instructions.
Extra segment (ES) is a 16-bit register containing address of 64KB segment,
usually with program data. By default, the processor assumes that the DI register
references the ES segment in string manipulation instructions. ES register can be
changed directly using POP and LES instructions.
It is possible to change default segments used by general and index registers by
prefixing instructions with a CS, SS, DS or ES prefix.
All general registers of the 8086 microprocessor can be used for arithmetic and
logic operations. The general registers are:
Accumulator register consists of two 8-bit registers AAL and AH, which can be
combined together and used as a 16-bit register AX. AL in this case contains the low-
order byte of the word, and AH contains the high-order byte. Accumulator can be used
for I/O operations and string manipulations.
Base registers consists of two 8-bit registers BL and BH, which can be combined
together and used as a 16-bit register BX. BL in this case contains the low-order byte of
the word, and BH contains the high-order byte. BX register usually contains a data
pointer used for based, based indexed or register indirect addressing.
Count registers consists of two 8-bit registers CL and CH, which can be
combined together and used as a 16-bit register CX. CL in this case contains the low-
order byte of the word, and CH contains the high-order byte. Count register can be used
as a counter in string manipulation and shift/rotate instructions.
Data registers consists of two 8-bit registers DL and DH, which can be combined
together and used as a 16-bit register DX. DL in this case contains the low-order byte of
the word, and DH contains the high-order byte. Data register can be used as a port
number in I/O operations. In integer 32-bit multiply and divide instructions the DX
register contains high-order word of the initial or resulting number.
The following registers are both general and index registers:
Stack Pointer (SP) is a 16-bit register pointing to program stack.
Base Pointer (BP) is a 16-bit register pointing to data in stack segment. BP
register is usually used for based, based indexed or register indirect addressing.
Source Index (SI) is a 16-bit register. SI is used for indexed, based indexed and
register indirect addressing, as well as a source data addresses in string manipulation
instructions.
Destination Index (DI) is 16-bit register. DI is used for indexed, based indexed
and register indirect addressing, as well as a destination data addresses in string
manipulation instructions. Other registers:
Instruction Pointer (IP) is a 16-bit register.
Flags are a 16-bit register containing 9 1-bit flags:
 Overflow Flag (OF) - set if the result is too large positive number, or is too small
negative number to fit into destination operand.
 Direction Flag (DF) – if set then string manipulation instructions will auto-
decrement index registers. If cleared then the index registers will be auto-
incremented.
 Interrupt-enable Flag (IF) – setting this bit enables masks able interrupts.
 Single-step Flag (TF) – if set then single-step interrupt will occur after the next
instruction.
 Sign Flag (SF) – set if the most significant bit of the result is set.
 Zero Flag (ZF) – set if the result is zero.
 Auxiliary carry Flag (AF) – set if there was a carry from or borrow to bits 0-3 in
the AL register.
 Parity Flag (PF) – set if parity (the number of “1” bits) in the low-order byte of the
result is even.
 Carry Flag (CF) – set if there was a carry from or borrow to the most significant
bit during last result calculation.

Conclusion:
Experiment No. 03
Introduction to emu8086
Objective:
The brief understanding of all the features of emu8086 software.

Theory:
Type your code inside the text area, and click compile button. we will be asked for
a place where to save the compiled file. After successful compilation you can click
emulate button to load the compiled file in emulator.

The output files type directives:


#make_com#
#make_bin#
#make_boot#
#make_exe#
You can insert these directives in the source code to specify the required output
type for the file.Only if compiler cannot determine the output type automatically and it
when it cannot find any of these directives it may ask for you for output type before
creating the file.
There is virtually no difference between how .com and .bin are assembled because
these files are raw binary files, but .exe file has a special header in the beginning of the
file that is used by the operating system to determine some properties of the executable
file.
Description of the output files types:
 #make_com# - the oldest and the simplest format of an executable file, such files
are loaded with 100h prefix (256 bytes). Select Clean from the New menu if you
plan to compile a COM file. Compiler directive ORG 100h should be added
before the code. Execution always starts from the first byte of the file. This file
type is selected automatically if org 100h directive is found in the code, supported
by DOS and Windows Command Prompt.
 #make_exe# - more advanced format of an executable file, not limited by size and
number of segments, stack segment should be defined in the program, you may
select exe template from the new menu in to create a simple exe program with
pre-defined data, stack and code segments, the entry point (where execution starts)
is defined by a programmer, this file type is selected automatically if stack
segment is found, supported by DOS and Windows Command Prompt.
 #make_bin# - a simple executable file. You can define the values of all
registers,segment and offset for memory area where this file will be loaded. When
loading “MY.BIN” file to emulator it will look for a “MY.BINF” file, and load
“MY.BIN” file to location specified in “MY.BINF” file, registers are also set
using information in that file (open this file in a text editor to edit or investigate),
in case the emulator is not able to find “MY.BINF” file, current register values
are used and “MY.BIN” file is loaded at current CS:IP, bin file type is not unique
to the emulator, however the directives are unique and will not work if .bin file is
executed outside of the emulator because their output is stored in a separate file
independently from pure binary code, .BINF file is created automatically if
assembler finds any of the following directives.
Assembly language compiler (or assembler) reports about errors in a separate
information window:
MOV DS, 100 – is illegal instruction because segment registers cannot be set directly,
general purpose register should be used, for example
MOV AX, 100
MOV AL, 300 – is illegal instruction because AL register has only 8 bits, and thus
maximum value for its 255 (or 11111111b), and minimum is – 128.
When saving an assembled file, compiler also saves 2 other files that are later
used by the emulator to show original source code when you run the binary executable,
and select corresponding lines. Very often the original code differs from the disabled
code because there are no comments, no segment and no variable declarations. Compiler
directives produce no binary code, but everything is converted to pure machine code
instructions, this is done mainly for the compatibility with original 8086 microprocessor
(for example ROL AAL, 5 is assembled into five sequential ROL AL, 1 instruction).

 *.asm – this file contains the original source code that was used to make an
executable file.
 *.debug – this file has information that enables the emulator select lines of
original source code while running the machine code.
 *.binf – this ASCII file contains information that is used by emulator to build file
at specified location, and set register values prior emulation.
Experiment No. 04
Arithmetic Operation

Objective:
To understand the assembly instructions for arithmetic operations.

Theory:
Arithmetic instruction: Microprocessor performs the arithmetic operations like
addition, subtraction multiplication and division.

Tool:
 Emulator EMU8086
 Intel Based computer

Procedure:

Follow the following procedure for arithmetic operations and observe the
new amendment as given in example.
Example 1:
Addition

MOV AX, 10

ADD AX, 20
MOV BX, AX

int 21h
Example 2:
Subtraction
MOV AX, 32
ADD AX, 10
MOV BX, AX

int 21h

Example 3:
Multiplication

MOV AX, 32

MOV BX, 10
MUL BX

int 21h

Example 4:
Division

MOV AX, 203 ; AX = 00CBh


MOV BL, 4
DIV BL ; AL = 50 (32h), AH = 3

Lab Tasks:
1. Compute the following equation using arithmetic functions in EMU8086.
Each time after
pressing the single step button, check and record down the contents of AX and
BX registers
in given table.

(2710+ 1510) * (62510-25010) + 191


2. Develop an assembly language program to perform the following arithmetic
operations by only using registers AX and BX.

710* (6410-4910) + 5310


Experiment No. 5

Objective:
Add, Multiplication, Push/Pop instruction

Theory:
Arithmetic instruction: Microprocessor performs the arithmetic operation like addition,
subtraction, multiplication and division.
PUSH:
It’s used to store data into stack using push operation stack pointer increased first and
then content of register or memory will store on that stack location which stored in SP.
PUSH Ax; SP increased by one and contain of R6 store into 08 location.
PUSH Ax; SP increased again by one and contain of R1 stored into 09 location.
POP:
To retrieve data from stack. In this retrieve data first and then stack pointer decreased by
one.
POP 20h; The content at 0Ah location will copy into 20h then stack pointer decrease by
1.
POP 21h; The content at 09h location will copy into 21h then stack pointer decrease by
1.
Example 1:

org 100h
mov ax, 5
add ax, 4
mov ax,bx
mul bx
push ax
pop ax
ret
Experiment No. 6
Objective:
To understand Addition, subtraction and compare instruction

Theory:
The Arithmetic logic unit (ALU) is used to perform arithmetic and logical instructions.
An ALU will, at minimum perform addition, subtraction, NOT, AND, OR and XOR and
usually single bit rotate and shift.

Addition:
Subtraction:

Comparison:
Experiment No. 7
Multiplication and division instruction
Objective:
To briefly understand the signed and unsigned multiplication and division instruction
process in assembly language.

Theory:
Mul: Unsigned multiply

Algorithm: When operand is byte: AX=AL* operand

When operand is a word: (DX AX)=AX* operand

IMUL: Signed multiply

Algorithm: When operand is a byte: AX=AL* operand

When operand is a word: (DX AX) =AX* operand

DIV: Unsigned divide

Algorithm: When operand is a byte: AX=AL/ operand and AH=remainder (modulus)

When operand is a word: AX= (DX AX)/ operand and DX= remainder (modulus)

IDIV: Signed divide

Algorithm: When operand is a byte: AL=AX/ operand and AH=remainder (modulus)

When operand is a word: AX= (DX AX)/ operand and DX= remainder (modulus)

Tools:
 Intel Pc
 Assembly 8086 software

Procedure
mov al,3
mov bl,2
mul bl
ret
MOV AX, 203 ; AX = 00CBh
MOV BL, 4
DIV BL ; AL = 50 (32h), AH = 3
RET
Experiment No.8

Objective:
To study and understand the Assembly Language Instructions for Basic Logic Operations

Theory:
The Intel 8086 Microprocessor instruction set contains instructions for performing basic logic
operations. The examples of these logic operations are AND, OR, XOR, TEST, NOT and
NEG instructions.

Tools:
 Emulator emu8086
 Intel Based Computer

Procedure:
Follow the following procedure for basic logic operations and observe the new ent
as given in example.

AND Instruction:
Logical AND between all bits of two operands. Result is stored in operand1.

These rules apply:

1 AND 1 = 1
1 AND 0 = 0
0 AND 1 = 0
0 AND 0 = 0

Example:

MOV AL,’a’ ; AL = 01100001b

AND AL,11011111b ; AL = 01000001b = ‘A’


OR Instruction:
Logical OR between all bits of two operands. Result is stored in first operand.

These rules apply:

1 OR 1 = 1
1 OR 0 = 1
0 OR 1 = 1
0 OR 0 = 0

Example:

MOV AL, 'A' ; AL = 01000001b

OR AL, 00100000b ; AL = 01100001b ('a')

RET

XOR Instruction:
Logical XOR (Exclusive OR) between all bits of two operands. Result is stored in first
operand.

These rules apply:

1 XOR 1 = 0
1 XOR 0 = 1
0 XOR 1 = 1
0 XOR 0 = 0

Example:

MOV AL, 00000111b

XOR AL, 00000010b ; AL = 00000101b

RET
Experiment No. 9

Objective:
To understand how jump work in assembly Language Instructions and how to make if else , switch
and loop through jump instruction.

Theory:
A jump instruction performs an unconditional jump, like an instruction transfers the flow of
execution by changing the instruction pointer registers. There are a number of different opcodes
that perform a jump, an override instruction is used, the instruction may take 16-bit,32-bit or
segment: offset pointers.

Tools:
 Emulator emu8086
 Intel Based Computer

Procedure:
Follow the following procedure for basic amendment as given in example.
Experiment No. 10

Objective:
To study and understand the functionality of all five loop instructions and their implementation in
different scenarios.

Theory:
The Intel 8086 Microprocessor instruction set contains instructions for performing basic looping
operations. The examples of these logic operations are LOOP, LOOPE, LOOPNE etc. instructions.

Tools:
 Emulator emu8086
 Intel Based Computer

Procedure:
Follow the following procedure for basic looping operations and observe the new
amendment as given in example.

Loop Instruction.
Decrease CX, jump to label if CX not zero.

Algorithm:

CX = CX - 1

if CX <> 0 then

jump

else

no jump, continue

Example:

MOV AL,1

MOV DI,2000H

MOV CX,10

HERE: MOV [DI],AL

INC AL

INC DI

Loop HERE

RET
LOOPE Instruction.
Decrease CX, jump to label if CX not zero and Equal (ZF = 1).

Algorithm:

CX = CX - 1

if (CX <> 0) and (ZF = 1) then

jump

else

no jump, continue

Example:

; Loop until result fits into AL alone,


; or 5 times. The result will be over 255
; on third loop (100+100+100),
; so loop will exit.

include 'emu8086.inc'

ORG 100h

MOV AX, 0

MOV CX, 5

label1:

ADD AX, 100

CMP AH, 0

LOOPE label1

RET
Experiment No. 14

Objective:
To Study 8051 Microcontroller Using The Keil Software and Create Hex File

Theory:
The Keil C51 C Compiler for the 8051 microcontroller is the most popular 8051 C compiler in the
world. It provides more features than any other 8051 C compiler available today.

The C51 C Compiler allows you to write 8051 microcontroller applications in C that, once compiled,
have the efficiency and speed of assembly language. Language extentions in the C51 Compiler give
you ful access to all resources of the 8051.

Procedure:
Experiment No. 15

Objective:
To Implement the IC Burning

IC Burning:
Programming or burning a microcontroller means to transfer the program from the compiler to the
memory of the microcontroller. A compiler is software which provides an environments to write ,
test and debug a program for the controller. The program for a controller is generally written in C
language.
In order to know how to program a microcontroller, we need a device called a burner/programmer.
A burner is a hardware device with dedicated software which reads the contents of hex file stored
on the PC or laptop and transferred it to the PC or USB cable and transfers the data to the memory
of the microcontroller to be programmed.

Tools:
 SUPER PRO M SERIES SOFTWARE
 IC BURNER

Procedure:
Experiment No. 16
Objective:
To Implement the Micro C Software For PIC Microcontroller

Theory:

Micro-controller operating system is a real time operating system design by embedded


software developer; Jean J. Labrosse in 1991.It is a priority-based pre-emptive real time for
microprocessor, written mainly in the C programming language. It is intended for use in
embedded systems.
Micro C/OS allows you to define several functions in C, each of the which can execute as an
independent thread or task. Each task runs at a different priority, and thinks that it own the
CPU. Lower priority tasks can be preempted by higher priority task at any time. Higher
priority task use operating system services to allow lower system tasks to execute.
There are operating system services provided for task management, inter task
communication, memory management, and for timing.

Procedure:
APLLICATION:
 Avionics
 Medical equipment
 Data communication equipment
 White goods
 Mobile phones, PHDS,MIDS
 Industrial control
 Consumer electronics
 Automotive

You might also like