0% found this document useful (0 votes)
67 views

MP Assignment

The document contains 5 assembly language programming problems and their solutions: 1. A program to calculate the summation of two decimal numbers entered by the user. 2. A program to calculate the summation of the first n numbers. 3. A program to check if a letter entered by the user is a vowel or consonant. 4. A program to take a hexadecimal digit as input and display its decimal equivalent on the next line. 5. A program to print a pattern of 6 rows with 4 asterisks in each row.
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)
67 views

MP Assignment

The document contains 5 assembly language programming problems and their solutions: 1. A program to calculate the summation of two decimal numbers entered by the user. 2. A program to calculate the summation of the first n numbers. 3. A program to check if a letter entered by the user is a vowel or consonant. 4. A program to take a hexadecimal digit as input and display its decimal equivalent on the next line. 5. A program to print a pattern of 6 rows with 4 asterisks in each row.
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/ 15

BUBT

Name : M. M. Tanvir Ahmed


Id : 17182103099
Intake : 38
Section : 03
1. Write an assembly language program that calculate the summation of
two decimal numbers

ans:

DATA SEGMENT
NUM1 DB ?
NUM2 DB ?
RESULT DB ?
MSG1 DB 10,13,"ENTER FIRST NUMBER TO ADD : $"
MSG2 DB 10,13,"ENTER SECOND NUMBER TO ADD : $"
MSG3 DB 10,13,"RESULT OF ADDITION IS : $"
ENDS
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MSG1
MOV AH,9
INT 21H
MOV AH,1
INT 21H
SUB AL,30H
MOV NUM1,AL
LEA DX,MSG2
MOV AH,9
INT 21H
MOV AH,1
INT 21H
SUB AL,30H
MOV NUM2,AL
ADD AL,NUM1
MOV RESULT,AL
MOV AH,0
AAA
ADD AH,30H
ADD AL,30H
MOV BX,AX
LEA DX,MSG3
MOV AH,9
INT 21H
MOV AH,2
MOV DL,BH
INT 21H
MOV AH,2
MOV DL,BL
INT 21H
MOV AH,4CH
INT 21H
ENDS
END START

2. Write an assembly language program that find out the summation of


first nth numbers.

1+2+3+4+------------------------+n

ans:

store macro res


div x
mov res,dl
mov dx,0
endm

ansprint macro res


mov dl,res
add dl,30h
mov ah,02h
int 21h
endm
data segment

number dw ?
result dw ?
msg db 10,13,"enter a last number to find sum $"
msgres db 10,13,"sum = $"

res db 8 dup(0)
x dw 10

data ends
code segment
assume cs:code,ds:data
start:

mov ax,data
mov ds,ax

mov dx,offset msg


mov ah,09h
int 21h

mov ah,01h
int 21h
sub al,30h
mov bh,al
mov ah,01h
int 21h
sub al,30h
mov bl,al
mov ax,bx
aad
mov bx,ax

mov number,ax
mov bx,0001h
mov ax,0000h
mov cx,number
label1:
add ax,bx
inc bl
loop label1

mov result,ax

mov dx,offset msgres


mov ah,09h
int 21h

mov dx,0000h
mov ax,result
store res+3
store res+2
store res+1
store res+0

ansprint res+0
ansprint res+1
ansprint res+2
ansprint res+3

mov ax,4c00h
int 21h

code ends
end start

3. Write an assembly language program that check a letter is vowel or


consonant.

ans:

.MODEL SMALL
.STACK 100H
.DATA
VOWEL DB 0DH,0AH,'VOWEL$'
CONSONANT DB 0DH,0AH,'CONSONANT$'

.CODE
MAIN PROC

MOV AX,@DATA
MOV DS,AX

MOV AH,1
INT 21H
CMP AL,'A'
JE VL
CMP AL,'E'
JE VL
CMP AL,'I'
JE VL
CMP AL,'O'
JE VL
CMP AL,'U'
JE VL
CMP AL,'a'
JE VL
CMP AL,'e'
JE VL
CMP AL,'i'
JE VL
CMP AL,'o'
JE VL
CMP AL,'u'
JE VL
LEA DX,CONSONANT
MOV AH,9
INT 21H
JMP EXIT

VL:
LEA DX,VOWEL
MOV AH,9
INT 21H
EXIT:
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN

4. Write an assembly language program that take a Hexadecimal digit &


display it on the next line in decimal.

ans:

.MODEL SMALL
.STACK 100H

.DATA
MSG_1 EQU
MSG_2 EQU 0DH,0AH

PROMPT_1 DB MSG_1
PROMPT_2 DB MSG_2
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX

LEA DX, PROMPT_1


MOV AH, 9
INT 21H

MOV AH, 1
INT 21H

MOV BL, AL

LEA DX, PROMPT_2


MOV AH, 9
INT 21H

MOV AH, 2
MOV DL, 31H
INT 21H

SUB BL, 11H

MOV DL, BL
INT 21H

MOV AH, 4CH


INT 21H
MAIN ENDP
END MAIN

5. Write an assembly code that gives the output like that.


****
****
****
****
****
****
ans:
INCLUDE "EMU8086.INC"
.MODEL SMALL
.STACK 100H
.DATA
.CODE
MAIN PROC
MOV CX ,6
MOV BX ,4
L1:
PUSH CX
MOV CX,4
L2:
MOV AH,2
MOV DL,'*'
INT 21H
LOOP L2
PRINTN
POP CX
LOOP L1
MOV AH , 4CH
INT 21H
MAIN ENDP
END MAIN

You might also like