Professional Documents
Culture Documents
Aim: To perform the Square Root, Odd and Even & Parity Bits using Assembler
MASM 611.
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:
Sample Output:
Square Root = √81 = 9H
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
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
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.