You are on page 1of 9

Name : Mridul Jadon 20BCE1734

Exp.8: Square Root, Odd and Even & Parity Bits

Aim: To perform the Square Root, Odd and Even & Parity Bits using Assembler
MASM 611.

Tool Used: Assembler - MASM 611


Square Root of Perfect numbers
TO ASSEMBLE AND RUN: -
Execution of Code

• Mount C drive using C:\directory_of_masm_folder


• Give edit file_name.asm to start editing the code
• Give masm file_name.asm to execute file
• Give link file_name.obj to link executed file
• Give debug file_name.exe to view output
• Give ‘u’
• Give ‘g’ followed by the address of HLT or INT to view the values in registers

Algorithm:
• Initialize NUM as 51H
• Then initialize CX = 1 and AX = 1
• Then use loop, and check whether CX * AX =BX, if its equal then stop the loop, and
CX is the answer
• If its not equal then increment both CX and AX
Name : Mridul Jadon 20BCE1734

Program:
Name : Mridul Jadon 20BCE1734

Sample Input:

NUM = 51H (81 in decimal)

Sample Output:
Square Root = √81 = 9H

Register/ Memory Contents for I/O:

Snapshot of the Output:


Name : Mridul Jadon 20BCE1734

Check whether a number is even Or odd ?-


TO ASSEMBLE AND RUN:-

Execution of Code
• Mount C drive using C:\directory_of_masm_folder
• Give edit file_name.asm to start editing the code
• Give masm file_name.asm to execute file
• Give link file_name.obj to link executed file
• Give debug file_name.exe to view output
• Give ‘u’
• Give ‘g’ followed by the address of HLT or INT to view the values in registers

Algorithm:
initialize num as 8
then shift the bit to right by 1, and check whether CF is 1 or 0
if CF = 0, then the number is even and display EVEN
if CF = 1, then display ODD
Name : Mridul Jadon 20BCE1734

Program:
Name : Mridul Jadon 20BCE1734

Sample Input:

NUM = 8H

Sample Output:
EVEN

Register/ Memory Contents for I/O:


Name : Mridul Jadon 20BCE1734

Snapshot of the Output:

Find parity of a number


TO ASSEMBLE AND RUN:-

Execution of Code
• Mount C drive using C:\directory_of_masm_folder
• Give edit file_name.asm to start editing the code
• Give masm file_name.asm to execute file
• Give link file_name.obj to link executed file
• Give debug file_name.exe to view output
• Give ‘u’
• Give ‘g’ followed by the address of HLT or INT to view the values in registers

Algorithm:
• Initialize NUM as 10H
• Move CX as 8, BX as 0 and AX as number
• Then use loop, to access each digit.
• Use ROR to shift bits, and check the carry flag,
• If CF = 1, then increment BX, and loop till the last digit
Name : Mridul Jadon 20BCE1734

Program:
Name : Mridul Jadon 20BCE1734

Sample Input:
NUM = 10H

Sample Output:
Parity = 1

Register/ Memory Contents for I/O:

Snapshot of the Output:

RESULT-

Hence, the square root of number, check whether a number is even or odd
and find parity of a number, areperformed successfully using MASM611
assembler.

You might also like