Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

ASSEMBLY LANGUAGE

PROGRAMMING
Simple 8086 Assembly Language Programs with Explanation
•Assembly level programming is very important to low-level embedded system
 design is used to access the processor instructions to manipulate hardware. 
•It is a most primitive machine level language is used to make efficient code
that consumes less number of clock cycles and takes less memory as compared
to the high-level programming language.
•It is a complete hardware oriented programing language to write a program
the programmer must be aware of embedded hardware. Here, we are providing
basics of assembly level programming 8086.
Assembly Level Programming 8086
The assembly programming language is a low-level language
which is developed by using mnemonics. The microcontroller or
microprocessor can understand only the binary language like 0’s
or 1’s therefore the assembler convert the assembly language to
binary language and store it the memory to perform the tasks.
Before writing the program the embedded designers must have
sufficient knowledge on particular hardware of the controller or
processor, so first we required to know hardware of 8086
processor.
Simple Assembly Language Programs 8086
The assembly language programming 8086 has some rules such as
•The assembly level programming 8086 code must be written in upper case
letters
•The labels must be followed by a colon, for example:  label:
•All labels and symbols must begin with a letter
•All comments are typed in lower case
•The last line of the program must be ended with the END directive
•8086 processors  have  two other instructions to access the data, such as
WORD PTR – for word (two bytes), BYTE PTR – for byte.

Op-code:  A single instruction is called as an op-code that


can be executed by the CPU. Here the ‘MOV’ instruction is
called as an op-code.

Operands:  A single piece data are called operands that


can be operated by the op-code. Example, subtraction
operation is performed by the operands that are subtracted
by the operand.
Syntax: SUB b, c
8086 microprocessor assembly language programs
8086 microprocessor assembly language programs

Write a Program For Read a Character From The Keyboard


MOV ah, 1h                    //keyboard input subprogram
INT 21h            // character input
// character is stored in al
MOV c, al              //copy character from alto c

Write a Program For Reading and Displaying a Character


MOV ah, 1h            // keyboard input subprogram
INT 21h            //read character into al
MOV dl, al            //copy character to dl
MOV ah, 2h            //character output subprogram
INT 21h            // display character in dl
MODULAR
PROGRAMMING
The programs that we work nowadays are often too large.
As we can see the applications that we run today and the
software that we use are able to perform multiple functions
and hence they have large program codes. But, it is very
difficult to build or design such a large code all at once.
Also, it is very hard to maintain it afterward in cases of any
errors or malfunctioning because the errors are too difficult
to locate and correct. Also, it becomes difficult for multiple
members to work on the same program. This increases the
burden on one programmer of the entire project. To solve
this issue, the concept of modular programming was
proposed.
Often large Programs are split into various small independent tasks which can be
easily designed and implemented. This is known as modular programming.
The concept of modular programming provides various advantages over the
ancient method of programming. Some of them are listed as follows:

ADVANTAGES
•The program code becomes simple to understand.
•Reduced development time and reduced burden on developers as the different
person can work on each module now as a team.
•Debugging process becomes easier.
•In case of any error or crash, it is easy to locate and fix the error.
•The code reusability can be implemented through the concept of modular
programming. By doing so, we can avoid writing the same sequence of
instructions again and again in the program. This same sequence can be written
separately and can be used whenever needed.

The code reusability is a very important feature that modular


programming offers us. In the 8086 microprocessor, we implement it using
procedures and macros. The procedures and macros are the set of instructions
which are written separately in a code. This can be called from anywhere in the
mainstream of code.
ALP to Sort a set of unsigned integer numbers in ascending/ descending order using Bubble sort algorithm.
DATA SEGMENT
 
A DW 0005H, 0ABCDH, 5678H, 1234H, 0EFCDH, 45EFH
DATA ENDS
ASSUME CS: CODE, DS: DATA
CODE SEGMENT ds
START: MOV AX, DATA
 
MOV DS, AX MOV SI, 0000H MOV BX, A[SI]
DEC BX
 
X2: MOV CX, BX MOV SI, 02H
 
X1: MOV AX, A[SI]
INC SI
INC SI
CMP AX, A[SI]
XCHG AX, A[SI]
MOV A[SI-2], AX
X3: LOOP X1
DEC BX
JNZ X2
MOV AH, 4CH
INT 21H
CODE ENDS
END START

You might also like