8086 program to find Square Root of a number
Problem – Write an assembly language program in 8086 microprocessor to find square root of a number.
Example –
Algorithm –
- Move the input data in register AX
- Move the data 0000 in CX and FFFF in BX
- Add 0002 to the contents of BX
- Increment the content of CX by 1
- Subtract the contents of AX and BX
- If Zero Flag(ZF) is not set go to step 3 else go to step 7
- Store the data from CX to offset 600
- Stop
- M0V AX, [500] is used to move the data from offset 500 to register AX
- MOV CX 0000 is used to move 0000 to register CX
- MOV BX FFFF is used to move FFFF to register BX
- ADD BX, 02 is used to add BX and 02
- INC CX is used to increment the content of CX by 1
- SUB AX, BX is used to subtract contents of AX with BX
- JNZ 040A is used to jump to address 040A if zero flag(ZF) is 0
- MOV [600], CX is used to store the contents of CX to offset 600
- HLT is used end the program
Program –
OFFSET | MNEMONICS | COMMENT |
---|---|---|
0400 | MOV AX, [500] | AX <- [500] |
0404 | MOV CX, 0000 | CX <- 0000 |
0407 | MOV BX, FFFF | BX <- FFFF | 040A | ADD BX, 02 | BX = BX + 02 | 040E | INC CX | C = C + 1 | 040F | SUB AX, BX | AX = AX – BX | 0411 | JNZ 040A | JUMP to 040A if ZF = 0 | 0413 | MOV [600], CX | [600] <- CX | 0417 | HLT | Stop |
Explanation –
Please Login to comment...