0% found this document useful (0 votes)
9 views7 pages

Assembly Language Programming Examples

The document contains a series of assembly language programming tasks, including operations such as adding data bytes from specific memory addresses, moving values to registers, calculating squares and 2's complements, finding square roots, and sorting arrays. Each task is accompanied by a solution in assembly code. The programs demonstrate various fundamental programming concepts in assembly language, including memory manipulation and control flow.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views7 pages

Assembly Language Programming Examples

The document contains a series of assembly language programming tasks, including operations such as adding data bytes from specific memory addresses, moving values to registers, calculating squares and 2's complements, finding square roots, and sorting arrays. Each task is accompanied by a solution in assembly code. The programs demonstrate various fundamental programming concepts in assembly language, including memory manipulation and control flow.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

write a program to add a data Byte located at the offset address


0500H in the segment 2000H to another data Byte located at the
offset address 0600H in the segment 3000H.
sol.

MOV CX, 2000

MOV DS, CX

MOV AX, [500]

MOV CX, 3000

MOV DS, CX

ADD AX, [600]

2. write a program to move 0500H to register be BX AND CX and add


05H to each of them AND store the result in 0700H segment
address 5000H.
sol. MOV DS,AX
MOV BX,[0500H]
MOV CX,BX
MOV AX,[05H]
ADD BX,AX
ADD CX,AX
MOV BX,700H
3. Add the contents of memory locations 2000h:0500h to contents of
3000h:0600h and store the result in 5000h:0700h.
Sol. MOV CX,2000H
MOV DS,CX
MOV AX,[0500H]
MOV CX,3000H
MOV DS, CX
MOV BX,[0600H]
ADD AX,BX
MOV CX,5000H
MOV DS,CX
MOV [0700H],AX

4. write a program to find the square of a given number.


Sol. MOV AX, 6
ADD AX, 6
ADD AX, 6
ADD AX, 6
ADD AX, 6
ADD AX, 6
5. write a program to find 2'S complement of a given number.
Sol. mov ax, @data
mov ds, ax
mov ax, a
neg ax
mov ch, 04h
mov cl, 04h
mov bx, ax

6. write a program to find square root of a number.


Sol.
MOV AX, [500]

MOV CX, 0000

MOV BX, FFFF

ADD BX, 02

INC CX

SUB AX, BX

JNZ 040A

MOV [600], CX

7. write a program to arrange the given set of bytes in ascending


order.
Sol.

MOV SI, 500

MOV CL, [SI]

DEC CL

MOV SI, 500

MOV CH, [SI]

DEC CH
INC SI

MOV AL, [SI]

INC SI

CMP AL, [SI]

JC 41C

XCHG AL, [SI]

DEC SI

XCHG AL, [SI]

INC SI

DEC CH

JNZ 40F

DEC CL

JNZ 407

8. write a program to arrange the given set of bytes in descending


order.
Sol.

MOV SI, 500


MOV CL, [SI]

DEC CL

MOV SI, 500

MOV CH, [SI]

DEC CH

INC SI

MOV AL, [SI]

INC SI

CMP AL, [SI]

JNC 41C

XCHG AL, [SI]

DEC SI

XCHG AL, [SI]

INC SI
DEC CH

JNZ 40F

DEC CL

JNZ 407

9. write a program to find the largest number in the given set of 8 bit
numbers stored in a memory location 0500H in the segment
2000H.
sol.
MOV CX, 0FH
MOV AX, 2000H
MOV DS, AX
MOV SI, 0500H
MOV AL, [SI]
BACK: INC SI
CMP AL,[SI]
INC SI
CMP AL,[SI]
JNC NEXT
MOV AL,[SI]
NEXT: LOOP BACK

[Link] a program to find out the Even and Odd numbers from a
given set of 10 data bytes stored in memory location 4000H:400H.
sol.
START: XOR BX, BX
XOR DX, DX
MOV AX, DATA
MOV DS, AX
MOV CL, COUNT
MOV SI, OFFSET LIST
AGAIN: MOV AX, [ SI ]
ROR AX, 01
JC ODD
INC BX
JMP NEXT
ODD: INC DX
NEXT: ADD SI, 02
DEC CL
JNZ AGAIN
MOV AH, 4CH
INT 21H
CODE ENDS
END START

You might also like