Moe*_*ini 2 binary assembly decimal x86-16
我有一个单词,有4个单元格
RESULT DW 4 DUP(0)Run Code Online (Sandbox Code Playgroud)
例如,它将包含二进制数
MOV RESULT, 0H
MOV RESULT+2, 0H
MOV RESULT+4, 35A4H
MOV RESULT+6, E900H
现在结果包含以十进制方式0000000035A4E900H表示900000000.不是我想在显示器上打印900000000.
我该怎么办?
无论您使用何种语言转换为十进制以十进制打印都是相同的过程.两个过程中的一个.你可以从任何一端开始.假设您有一个16位数字12345(0x3039).
第一种方式是
divide by 10000 result is 1 remainder 2345 save or print the 1
divide by 1000 result is 2 remainder 345 save or print the 2
divide by 100 result is 3 remainder 45 save or print the 3
divide by 10 result is 4 remainder 5 save or print the 4 and 5
Run Code Online (Sandbox Code Playgroud)
第二种方式
divide by 10 result is 1234 remainder 5 save the remainder use the result
divide by 10 result is 123 remainder 4 save the remainder use the result
divide by 10 result is 12 remainder 3 save the remainder use the result
divide by 10 result is 1 remainder 2 save both the remainder and result
print the results in the right order
Run Code Online (Sandbox Code Playgroud)
现在,如果你的问题是我如何用我的指令集将64位数除以这些10的幂,有时你可以,有时你不能,有时你必须使用其他数学规则.除以10与除以2*5相同,因此可以除以2(移位)然后除以5.
0x3039(12345)除以10000与右移4相同,然后除以5得到功率4(625).0x303 = 771,771/612 = 1.如果你的除数不大,你的乘法可能不是这样1*625 = 0x271,0x271 << 4 = 0x2710,0x3039 - 0x2710 = 0x929 = 2345.一旦你得到一个你可以用硬件划分的数字,然后使用硬件.
你可能需要除以中间的一个数字,比如你有一个32位数字(最大4,294,967,296),你有硬件可以从32位数字分成16位结果和16位余数.您可以使用上述方法关闭几个数字,然后离开94,967,295然后除以10000得到9496余数7295然后使用硬件独立地处理这四位数字.
如果你没有除法硬件但是硬件倍增(是的我知道你指定了8086)你可以这样做:
http://www.divms.uiowa.edu/~jones/bcd/divide.html
如果你还记得小学,如何在铅笔和纸上做倍增:
1234
x1010
=====
0000
1234
0000
+1234
========
1246340
Run Code Online (Sandbox Code Playgroud)
二进制文件非常简单,因为您可能会根据我选择的数字进行描绘
abcd
x efgh
======
Run Code Online (Sandbox Code Playgroud)
如果你想将4位abcd乘以4位,那么:
result = 0;
if(h) result+=abcd << 0;
if(g) result+=abcd << 1;
if(f) result+=abcd << 2;
if(e) result+=abcd << 3;
Run Code Online (Sandbox Code Playgroud)
对于大多数指令集,您可以将多个指令级联为与内存一样宽,希望将100万位乘以100万位.没问题,500,000字节加一点或多个寄存器(以及很多时钟周期).