Aim:
To write an assembly language program to perform the following operations using
8086 Emulator.
a. Find square root of a number
b. String Manipulation – Reverse a String

Find square root of a number

Algorithm:
1. Open a new file in the Emu 8086
2. Load the data into AX register with address 5000H
3. Initialize BX register with 0001H and CL to 02
4. Subtract AL,BL and store result in AL
5. Jump on carry to AL
6. Increment CL
7. Add BL,02 and store the result in BL
8. Jump to CL
9. Move the content of CL to 5010H
10. Stop the program
Program:
MOV AL,[5000H];
MOV CL,0001H;
MOV BL,01H;
L2: SUB AL,BL;
JZ L1;
INC CL;
ADD BL,02H;
JMP L2;
L1: MOV [5010H],CL;
END

Reverse a string

Algorithm
1. Create a string
2. Traverse through the string
3. Push the characters in the stack
4. Count the number of characters
5. Load the starting address of the string
6. POP the top character of the stack until count is not equal to zero
7. Put the character and reduce the count and increase the address
8. Continue until the count is greater than zero
Program
MOV SI, [5000H];
MOV DI, [5010H];
MOV CX, 0008H;
ADD SI, 07H;
L1: MOV AL, [SI];
MOV [DI], AL;
DEC SI;
INC DI;
DEC CX;
JNZ L1;
HLT;