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

Assembly Language Programming Examples

The document provides assembly language programming examples for basic operations. It includes a program to add two 8-bit numbers, calculate the sum of the first 10 natural numbers, and swap the contents of two memory locations. Each example includes step-by-step instructions and comments explaining the purpose of each instruction.

Uploaded by

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

Assembly Language Programming Examples

The document provides assembly language programming examples for basic operations. It includes a program to add two 8-bit numbers, calculate the sum of the first 10 natural numbers, and swap the contents of two memory locations. Each example includes step-by-step instructions and comments explaining the purpose of each instruction.

Uploaded by

Utpal Ghosh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Assembly Language Programming

1. Add two 8-bit numbers

Two address

LXI H, 2501H : "Get address of first number in H-L pair. Now H-L points to 25
01H"
MOV A, M : "Get first operand in accumulator"
INX H : "Increment content of H-L pair. Now, H-L points 2502H"
ADD M : "Add first and second operand"
INX H : "H-L points 4002H"
MOV M, A : "Store result at 2503H"
HLT : "Stop"

2. Write an assembly language program to find the sum of a series


1+2+3+....+10 (or sum of first 10 natural numbers).
MVI B,0AH // Loads B-register with 0AH
MVI A,00H // Loads the accumulator with 00H
LOOP: ADD B // Adds the content of B-register to accumulator
DCR B // Decrements B-register
JNZ LOOP // Checks for No zero; if No zero jump to LOOP
STA 2500H // Stores the answer to memory location 2500H
HLT // Stop processing
3. Write an assembly language program to interchange (swap) the
contents of two memory locations 2100 H and 2101 H.
LDA 2100H // Loads the content of 2100H into accumulator
MOV B,A // Moves the content of accumulator to B-
register
LDA 2101H // Loads the content of 2101H into
accumulator
STA 2100H // Loads the accumulator content to 2100 H
location
MOV A,B // Moves the content of B-register to
accumulator
STA 2101H // Loads the accumulator content to 2101 H
location
HLT // Stop processing

You might also like