平方根二分查找_查找数字的平方根| 8086微处理器

平方根二分查找

Problem: Write a program in 8086 microprocessor to find square root of a number.

问题:在8086微处理器中编写程序以查找数字的平方根。

Algorithm:

算法:

  1. Move the firstnumber in register AX.

    将第一个数字移到寄存器AX中。

  2. Assign the value of register CX as 0000 and register BX as FFFF.

    将寄存器CX的值分配为0000,将寄存器BX的值分配为FFFF。

  3. Add 0002 to value of register BX.

    将0002加到寄存器BX的值上。

  4. Update the value of register CX by one.

    将寄存器CX的值更新1。

  5. Subtract the content of register AX and BX.

    减去寄存器AX和BX的内容。

  6. If the value of zero flag is not set then goto step 3 otherwise goto next step.

    如果未设置零标志的值,则转到步骤3,否则转到下一步。

  7. Store the value of CX to memory.

    将CX的值存储到内存中。

  8. 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

平方根二分查找

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值