1. Green University of Bangladesh
Department of Computer Science and Engineering (CSE)
Faculty of Sciences and Engineering
Semester: (Spring, Year: 2021), B.Sc. in CSE (Day)
LAB REPORT NO #02
Course Title: Microprocessor and microcontroller Lab
Course Code: CSE - 304 Section: 192DD
Lab Experiment Name: Write program to find factor and check even and odd by
user input.
Student Details
Name ID
1. Shakh Farid 192002038
Lab Date : 13. 07. 2021
Submission Date : 26. 07. 2021
Course Teacher’s Name : Md. Parvez Hossian
[For Teachers use only: Don’t Write Anything inside this box]
Lab Report Status
Marks: ………………………………… Signature:.....................
Comments:.............................................. Date:..............................
2. 1. TITLE OF THE LAB EXPERIMENT
Write program to find factor and check even and odd by user input.
2. OBJECTIVES/AIM
To learn how to write program for factor and check even and odd by user input.
3. PROCEDURE / ANALYSIS / DESIGN
Even and Odd Number: If a number is exactly divisible by 2 then its an even
number else it is an odd number. In this article we have shared two ways(Two C
programs) to check whether the input number is even or odd. 1) Using Modulus
operator(%) 2) Using Bitwise operator.
Factors: A number which divides completely the number “N” is called the factor of
the number “N”. For example:- the numbers 1, 2, 3, 4, 6 and 12 are complete divides
the number 12 so they are called the factor of 12. Completly divisible means when
we divide the number then it gives result zero.
To find the factor of a positive number “N” divide that number using natural
numbers 1 to “N”. If the number is divisible by the natural number then that
natural number is the factor. A number N can have factors only in between 1 to N.
3. Steps to find the factors of a number:-
1) Take a number N as input
2) Take an iterator variable and initialize it with 1
3) Dividing the number N with an iterator variable
4) If it is divisible then it is a factor of the given number N
5) Increase the iterator variable
6) Repeat the 4 and 5 steps until the iterator variable becomes equal to N.
4. IMPLEMENTATION
Check Even or Odd:
; You may customize this and other start-up templates;
; The location of this template is c:emu8086inc0_com_template.txt
org 100h
.data
str db 'Enter a Number:$'
a db 'EVEN$'
b db 'ODD$'
n_line db 0ah, 0dh,'$'
.code
mov ax, @data
mov ds, ax
mov ax, 0
lea dx, str
mov ah, 09h
int 21h
mov ah, 01h
int 21h
mov bl, 2
div bl
lea dx, n_line
mov ah, 09h
4. int 21h
cmp ah, 0
je even
odd:
lea dx, b
mov ah, 09h
int 21h
jmp Exit
even:
lea dx, a
mov ah, 09h
int 21h
Exit:
ret
Find Factor:
; You may customize this and other start-up templates;
; The location of this template is c:emu8086inc0_com_template.txt
org 100h
.data
input db 'Enter a Number:$'
num db ?
n_line db 0ah, 0dh,'$'
.code
main proc
5. mov ax, @data
mov ds, ax
lea dx, input
mov ah, 09h
int 21h
mov ah, 01h
int 21h
sub al, 48
mov num, al
lea dx, n_line
mov ah, 09h
int 21h
mov cl, num
mov bl, 0
Factor:
mov ax, 0
inc bl
mov al, num
div bl
cmp ah, 0
je print
Exit:
jmp close
print:
mov dl, bl
add dl, 48
mov ah, 02h
int 21h
7. 6. ANALYSIS AND DISCUSSION
1. This experiment, I was learn about factor number and how to check even or
odd number.
2. I was implement two program one is find factor and another one is check even
or odd numbers. To implement those programs I use emu8086 IDE.
3. When I implement those program, I was faced some problem. When I used
loop, I couldn’t apply.
4. This experiment I also learn about JMP command and CMP command. I used
those two command in my program.
7. SUMMARY:
In this experiment, I learn about factor and even or odd number, and how to
implement program in assembly language.