MIC Project Report2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Title of Micro Project:

Develop an assembly language program to:

1. Check whether a given number is Armstrong or not.


2. Check whether a given string is Palindrome or not.
3. Count number of vowels and consonants in string.

➢ Introduction:
8086 Microprocessor was the first 16-bit microprocessor developed by Intel Corporation. This
8086 Microprocessor have 40 pins and is operate at 5 volts DC supply.

For this subject we have done this project using the MACRO directive. In this whole micro-
project, we worked on three sub projects which includes operations on strings and numbers as
well. In this project we have developed three sub-projects such as:

1. Check whether number is Armstrong or not.


An Armstrong number means a number that is equal to sum of the cubes of its own
digits.
2. Check whether the string is Palindrome or not.
Within this sub-project we have checked a string palindrome or not means we provided
a string and checked after reversing that string it is equal to original string. If it is equal
to that original string then the string is Palindrome.
3. Count number of vowel and consonants within given string.
Within this we calculated number of vowels and consonants in a given string using
macros.
We worked together on these projects and developed well programs to do these
tasks.

➢ Aim of micro project:


1. Analyze the functional block of 8086 Microprocessor.
2. Write assembly language program for given problem.
3. Use instructions for different addressing modes.
4. Develop an assembly language program using assembler.
5. Develop assembly language programs using macros.

1|Page
1. Write assembly language program to check whether number is
Armstrong or not.

➢ Algorithm:
Step 1: Start
Step 2: Initialize data segment.
Step 3: Read number from user.
Step 4: Calculate cube of each digit of number.
Step 5: Make addition of cube of digits.
Step 6: Addition = number go to step
Step 7: Print number is Armstrong.
Step 8: Print number is not Armstrong.
Step 9: Stop.

➢ Flowchart:

2|Page
➢ Program:
.model small

armstrong macro num1,num2,divis,quo,rem,sum,dec_num,msg1,msg2


mov cx,04h
mov ax,num1
mov num2,ax
next:
mov ax,num2
cwd
div divis
mov quo,ax
mov rem,dx
mov ax,rem
mul rem
mul rem
mov bx,ax
add sum,bx
mov bx,sum
mov ax,quo
mov num2,ax
dec cx
jnz next

mov ch,00h
mov bx,0ah
mov ax,sum
rpt:
mov dx,00
div bx
push dx
inc ch
cmp ax,0ah
jge rpt

inc ch
mov cl,12
rpt3:
and ax,0fh
shl ax,cl

add dec_num,ax
sub cl,4
pop ax

3|Page
dec ch
jnz rpt3
mov ax,dec_num
mov cl,04h
ror ax,cl
mov dec_num,ax
mov ax,num1
cmp ax,dec_num
jz dn
mov ah,09h
lea dx,msg2
int 21h
jmp exit
dn:
mov ah,09h
lea dx,msg1
int 21h
exit:
mov ah,4ch
int 21h
endm

.data
num1 dw 153h
num2 dw 0
divis dw 10h
quo dw 0
rem dw 0
sum dw 0
dec_num dw 0
msg1 db 'number is armstrong$'
msg2 db 'number is not armstrong$'
.code
mov ax,@data
mov ds,ax

armstrong num1,num2,divis,quo,rem,sum,dec_num,msg1,msg2

ends
end

4|Page
➢ Output:

2. Write assembly language program to check whether string is


Palindrome or not.
➢ Algorithm:
Step 1: Start.
Step 2: Initialize data segment.
Step 3: Call MACRO form main program.
Step 4: Get address of end of the string, SI
Step 5: Load the starting address of string DI
Step 6: Compare value stored at address SI and DI.
Step 7: Increment destination memory pointer.
Step 8: Decrement source memory pointer.
Step 9: If Di<=SI then go to step 6.
Step 10: End MACRO.
Step 11: If source string equals to destination string print string is palindrome.
Step12: Else print string is not palindrome.
Step13: Stop.

5|Page
➢ Flowchart

➢ Program:
palindrome MACRO STRING, STRING1, STRING2
MOV SI, OFFSET STRING

LOOP1:
MOV AL, [SI]
CMP AL, '$'
JE LABEL1
INC SI
JMP LOOP1
LABEL1:
MOV DI, OFFSET STRING
DEC SI
LOOP2:
CMP SI, DI
JL OUTPUT1
MOV AL, [SI]
MOV BL, [DI]
CMP AL, BL
JNE OUTPUT2
DEC SI
6|Page
INC DI
JMP LOOP2

OUTPUT1:
LEA DX, STRING1
MOV AH,09H
INT 21H
RET
OUTPUT2:
LEA DX, STRING2
MOV AH,09H
INT 21H
RET
ENDM

.data
STRING DB 'ABBA$'
STRING1 DB 'STRING IS PALINDROM$'
STRING2 DB 'STRING IS NOT PALINDROME$'
.code
MOV AX, @data
MOV DS, AX
mov es, ax
palindrome STRING, STRING1, STRING2
MOV AH,4CH
INT 21H
ENDS
END

➢ Output:

7|Page
3. Write assembly language program to count vowels and consonants in
a string.
➢ Algorithm
Step 1: Start.
Step 2: Initialize data segment
Step 3: Initialize vowel and consonant counter.
Step 4: Initialize memory pointer to read string.
Step 5: Call MACRO from main program.
Step 6: Read character.
Step 7: If character equals to vowel, then go to step 9.
Step 8: Increment consonant counter.
Step 9: Increment vowel counter.
Step 10: Increment memory pointer.
Step 11: Go to step 6 until last character.
Step 12: Stop.

➢ Flowchart

8|Page
➢ Program:
.MODEL SMALL

COUNTV_W MACRO STR1,COUNT_V, COUNT_C


START:
MOV AL, [SI] ;READ FIRST CHARACTER
CMP AL,'$' ;CHECK END OF STRING
JE EXIT ;EXIT IF END OF STRING

CMP AL,'A' ;CHECK FOR VOWEL CHARACTER


JE COUNT
CMP AL,'a'
JE COUNT
CMP AL,'E'
JE COUNT
CMP AL,'e'
JE COUNT
CMP AL,'I'
JE COUNT
CMP AL,'i'
JE COUNT
CMP AL,'O'
JE COUNT
CMP AL,'o'
JE COUNT
CMP AL,'U'
JE COUNT
CMP AL,'u'
JE COUNT
INC COUNT_C ;INCREMENT CONSONANT COUNTER
JNE MOVE

COUNT:
INC COUNT_V ;INCREMENT VOWEL COUNTER

MOVE:
INC SI ;INCREMENT MEMORY POINTER TO READ NEXT
NUMBER
JMP START ;GOTO START LABLE AGAIN.

9|Page
EXIT:
MOV BL, COUNT_V ;STORE VOWEL COUNT IN BL
MOV DL, COUNT_C ;STORE CONSONANT COUNT IN BL
ENDM

.DATA
STR1 DB 'ADITYABUC$' ;INPUT STRING
COUNT_V DB 0
COUNT_C DB 0
.CODE
MOV AX, @DATA ;INITIALIZE DATA SEGMENT
MOV DS, AX
MOV SI, OFFSET STR1 ;INITIALIZE MEMORY POINTER

COUNTV_W STR1, COUNT_V, COUNT_C ;CALLING TO MACRO

MOV AH,09H
INT 21H
ENDS
END

➢ Output:

10 | P a g e
➢ Resources Used:
Name of
Sr.no. required Specification Quantity Remarks
resources

Hardware (i3-i5 preferable), RAM at


1. 1 Each
(pc/laptop) least 2 GB

Operating
2. Windows 7+ 1 Each
System
Software:
Editor EDIT/Notepad
3. Assembler TASM/MASM 1 Each
Linker TLINK/LINK
Debugger TD/DEBUG
Microprocessor and
4. Reference Book 1
Interfacing
Laboratory Diploma Semester IV
5. 1 Each
Manual Microprocessors
https://www.tutorialspoint.
Online com/assembly_programmin
6. -
Reference g/index.htm

➢ Skills Developed:

1. Improved the ability to work quickly and with team members.


2. Improved communication and presentation skills.
3. Improved ability to do any work wholeheartedly with team.
4. Improved Ability to use inheritance.
5. Improved Ability to write different classes and functions.
6. Ability to handle exceptions also improved.

11 | P a g e

You might also like