装配8086问题没有mul和div

时间:2014-05-05 10:01:32

标签: assembly

我有一些装配8086的问题(没有mul / div):

如何在没有mul和div的情况下进行此练习:

1)bx←bx×32C(1行)

2)bx←bx×41(5行)

3)bx←bx×63

4)bx←bx / 16

感谢您的帮助!

1 个答案:

答案 0 :(得分:2)

它们都是一些相当简单的移位/算术运算,下面实现了两个(未经测试),其余的提示;

1)bx←bx×32C(1行)

# A left shift by 5 positions is a multiplication by 32
shl $5, %ebx

2)bx←bx×41(5行,clobbering eax)

# Add ebx + 8*ebx + 32*ebx = 41*ebx
mov %eax, %ebx
shl $3,   %ebx
add %eax, %ebx
shl $2,   %ebx
add %ebx, %eax

3)bx←bx×63

# Calculate 64*ebx - ebx = 63*ebx

4)bx←bx / 16

# A shift right by 4 is a division by 16