shr和shl的2的幂-组装 [英] power of 2 with shr and shl - Assembly
本文介绍了shr和shl的2的幂-组装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何在组装* 86中用shl和shr乘以2的幂?
How I can make a power of 2 with shl and shr in assembly *86 ?
我需要做2 ^ 13.
I need to do 2^13.
我尝试过但没有成功:(
I tried but without success :(
我正在将8086汇编与emu8086配合使用.
I'm using 8086 assembly with emu8086.
这是我的尝试:
org 100h
mov ax,1 ; ax = 1.
shl ax,13
mov ah, 0
int 16h
ret
我的问题是如何用16位而不是8位表示.
My problem is how to present that in 16 bits and not in 8 bits.
推荐答案
这是一个简单的数学问题.您想要的是什么
It's a simple math problem. What you want is this:
mov ax,1
shl ax,13
这将为您提供1 * 2 ^ 13而不是2 * 2 ^ 13 = 2 ^ 14,这正是您的代码所要做的.
That will give you 1*2^13 instead of 2*2^13 = 2^14 which is what your code does.
这篇关于shr和shl的2的幂-组装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文