delay with MOV/LOOP

Typical Pentium software delay loops can be written using MOV and LOOP instructions.
For example, the following instruction sequence can be used for a delay loop: MOV CX,countDELAY: LOOP DELAY
The initial loop counter value of “count” can be calculated using the cycles required to execute the following Pentium instructions:MOV reg/imm (1 cycle)LOOP label (5/6 cycles)
Note that the Pentium LOOP instruction requires two different execution times. LOOP requires six cycles when the Pentium branches if the CX is not equal to zero after autodecrementing CX by 1. However, the Pentium goes to the next instruction and does not branch when CX = 0 after autodecrementing CX by 1, and this requires five cycles.
This means that the DELAY loop will require six cycles for (count - 1) times, and the last iteration will take five cycles.
For a 100-MHz Pentium clock, each cycle is 10 ns. For 2 ms, total cycles =2ms/10ns= 200,000. The loop will require six cycles for (count - 1) times when CX + 0, and five cycles will be required when no branch is taken (CX = 0). Thus, total cycles including the MOV = 1 + 6 x (count - 1) + 5 = 200,000. Hence, count = 33,333,0. Therefore, CX must be loaded with 33,33310

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值