80286:乘以10最快的方法是什么? [英] 80286: Which is the fastest way to multiply by 10?

查看:84
本文介绍了80286:乘以10最快的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要将数字乘以2的任意倍数,我将对其进行多次移位.

To multiply a number by any any multiple of 2, I'll shift it those many times.

是否有这种技术可以在更少的周期内将数字乘以10?

Is there any such technique to multiply a number by 10 in less cycles?

推荐答案

80286没有随80386一起推出的桶形移位器.根据Microsoft Macro Assembler 5.0文档(1987)中的时序表, SHL reg,immed8 需要5个n周期,而 SHL reg, 1 需要2个周期. ADD reg,reg MOV reg,reg 一样,需要2个周期. IMUL reg16,immed 需要21个周期.因此,最快的乘以十的方法似乎是:

The 80286 did not have a barrel shifter, that was introduced with the 80386. According to the timing tables in the Microsoft Macro Assembler 5.0 documentation (1987), SHL reg, immed8 takes 5+n cycles, whereas SHL reg, 1 takes 2 cycles. ADD reg, reg takes 2 cycles, as does MOV reg, reg. IMUL reg16, immed takes 21 cycles. Therefore, the fastest way to multiply by ten would appear to be:

           ;       // cycles
shl ax, 1  ; *2    // 2
mov bx, ax ; *2    // 4
shl ax, 1  ; *4    // 6
shl ax, 1  ; *8    // 8
add ax, bx ; *10   // 10

或者,或者:

           ;      // cycles
mov bx, ax ; *1   // 2
shl ax, 1  ; *2   // 4
shl ax, 1  ; *4   // 6
add ax, bx ; *5   // 8
shl ax, 1  ; *10  // 10

两种方式都循环十次.

这篇关于80286:乘以10最快的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆