平方根二分查找
Problem: Write a program in 8086 microprocessor to find square root of a number.
问题:在8086微处理器中编写程序以查找数字的平方根。
Algorithm:
算法:
Move the firstnumber in register AX.
将第一个数字移到寄存器AX中。
Assign the value of register CX as 0000 and register BX as FFFF.
将寄存器CX的值分配为0000,将寄存器BX的值分配为FFFF。
Add 0002 to value of register BX.
将0002加到寄存器BX的值上。
Update the value of register CX by one.
将寄存器CX的值更新1。
Subtract the content of register AX and BX.
减去寄存器AX和BX的内容。
If the value of zero flag is not set then goto step 3 otherwise goto next step.
如果未设置零标志的值,则转到步骤3,否则转到下一步。
Store the value of CX to memory.
将CX的值存储到内存中。
Terminate the program.
终止程序。
Program:
程序:
MOV AX, [0600]
MOV CX, 0000
MOV BX, FFFF
*** ADD BX, 02
INC CX
SUB AX, BX
JNZ ***
MOV [0602], CX
HLT
Observation:
观察:
INPUT:
0600:19
0601:00
OUTPUT:
0602:05
Hence, we successfully calculated the square root of a number using 8086 Microprocessor.
因此,我们使用8086微处理器成功计算了数字的平方根 。
翻译自: https://www.includehelp.com/embedded-system/square-root-of-a-number.aspx
平方根二分查找