Header Ads

Header ADS

Program for Addition of two 8-bit numbers using External Memory

Introduction

Hello friends, In this post, we will learn how to write a simple program in Assembly language for addition of two 8-bit numbers.using internal memory.
Assembly language is a low level programming language.With the invention of many high level languages, the use of assembly language has become rare these days. However, it is true that every high level language must be compiled into assembly language before it can be linked into an executable program. For the high level language programmer, understanding how the compiler generates the assembly language code can be a great benefit, both for directly writing routines in assembly language and for understanding how the high-level language routines are converted to assembly language by the compiler.

One of the first hurdles to learning assembly language programming is understanding just what
assembly language is. Unlike other programming languages, there is no one standard format that
all assemblers use. Different assemblers use different syntax for writing program statements.
Many beginning assembly language programmers get caught up in trying to figure out the myriad
of different possibilities in assembly language programming.

The first step is to deciding what type of assembly language programming one want. Once you decided then it is easy to start learning. Each family of processors has its own set of instructions for handling various operations like getting input from keyboard, displaying information on screen and performing various other jobs. These set of instructions are called 'machine language instruction'.Processor understands only machine language instructions which are strings of 1s and 0s. However machine language is too obscure and complex for using in software development. So the low level assembly language is designed for a specific family of processors that represents various instructions in symbolic code and a more understandable form.

Program

;PROGRAM FOR ADDITION OF TWO 8-BIT NUMBERS USING EXTERNAL MEMORY

ORG 00H                                          ;STARTING OF CODE MEMORY AT 00H
SJMP MAIN                                     ;SHORT JUMP TO LABEL MAIN
ORG 30H                                          ;STARTING OF CODE MEMORY AT 30H

MAIN :

MOV DPTR,#2000H                        ;DPTR->2000H
MOVX A,@DPTR                           ;A->@DPTR->@2000H->10H
MOV R0,A                                       ;R0->A->10H
MOV DPTR,#2001H                       ;DPTR->2001H
MOVX A,@DPTR                          ;A->@DPTR->@2001H->23H
ADD A,R0                                       ;ADD(35+16)A->33H
INC DPTR                                       ;DPTR->2002H
MOVX @DPTR,A                          ;@DPTR->@2002H->A->33H
END                                                 ;INDICATES END OF ASSEMBLY CODE




No comments

Powered by Blogger.