0% found this document useful (0 votes)
204 views18 pages

Assignment Comsats University Vehari Campus

The document contains instructions for an assignment and 4 assembly language programming problems: 1. Write a program to input two numbers and perform addition and subtraction. 2. Write a program to input a number and check if it is negative or non-negative. 3. Write a program to input a string and display its reverse. 4. Write a program to input 3 strings and display each on a new line.
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)
204 views18 pages

Assignment Comsats University Vehari Campus

The document contains instructions for an assignment and 4 assembly language programming problems: 1. Write a program to input two numbers and perform addition and subtraction. 2. Write a program to input a number and check if it is negative or non-negative. 3. Write a program to input a string and display its reverse. 4. Write a program to input 3 strings and display each on a new line.
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
You are on page 1/ 18

Instructions:

Write down your name and registration number on the top of every page.
Send your document in pdf form on given email.

[email protected]

1. Write Down an assembly program to input two numbers from user and
perform addition and subtraction on them.

Output:

Enter First Number:5

Enter Second Number:4

Addition=9

Subtraction=1

.model small
.stack 100h

.data

.code

main proc

mov ax,'2'

mov bx,'1'

push ax

push bx

pop ax

pop bx

mov dx,ax

mov ah,2

int 21h

mov dx,bx
mov ah,2

int 21h

mov ah,4ch

int 21

main endp

end main
2. Write down an Assembly Program to input a number from user and
check whether Number is Negative or Not?
.model small

.stack 100h

.data

var db 10 DUP('$')

msg1 db 10,13,'Number is Negative$'

msg2 db 10,13,'Number is NonNegative$'

.code

main proc

mov ax,@data

mov ds,ax

mov si,offset var


l1:

mov ah,1

int 21h

cmp al,13

je check

mov [si],al

inc si

jmp l1

check:

cmp var,'-'

je l2

mov dx,offset msg2

mov ah,9

int 21h
jmp exit

l2:

mov dx,offset msg1

mov ah,9

int 21h

exit:

mov ah,4ch

int 21

main endp

end main
3. Write down an assembly program to input an string from user and then
display its reverse?

.model small

.stack 100h

.data

string1 db 'ABC'

.code

main proc
mov ax,@data

mov ds,ax

mov si,offset string1

mov cx,3

l1:

mov bx,[si]

push bx

inc si

Loop l1

mov cx,3
l2:

pop dx

mov ah,2

int 21h

Loop l2

mov ah,4ch

int 21h

main endp

end main
4. Write an Assembly code to display three string variables on three
different lines?

.model small

.stack 100h

.data

string1 db 10DUP('$')

string2 db 10DUP('$')

string3 db 10DUP('$')
.code

main proc

mov ax,@data

mov ds,ax

mov si,offset string1

loop1:

mov ah,1

int 21h

cmp al,13

je loopend

mov [si],al

inc si
jmp loop1

loopend:

mov dx,offset string1

mov ah,9

int 21h

mov dx,10

mov ah,2

int 21h

mov dx,13

mov ah,2

int 21h
mov si,offset string2

loop2:

mov ah,1

int 21h

cmp al,13

je loopend2

mov [si],al

inc si

jmp loop2
loopend2:

mov dx,offset string2

mov ah,9

int 21h

mov dx,10

mov ah,2

int 21h

mov dx,13

mov ah,2

int 21h
mov si,offset string3

loop3:

mov ah,1

int 21h

cmp al,13

je loopend3

mov [si],al

inc si

jmp loop3

loopend3:

mov dx,offset string3

mov ah,9
int 21h

mov ah,4ch

int 21h

main endp

end main

You might also like