本文介绍了汇编器:为什么BCD存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您不了解二进制文件,我知道BCD就像更直观的数据类型.但是我不知道为什么要使用这种编码,因为它很浪费,所以没有什么意义表示形式为4位(表示形式大于9时).

I know BCD is like more intuitive datatype if you don't know binary.But I don't know why to use this encoding, its like don't makes a lot of sense since its wasterepresentation in 4bits (when representation is bigger than 9).

我还认为x86仅直接支持add和subs(您可以通过FPU对其进行转换).

Also I think x86 only supports adds and subs directly (you can convert them via FPU).

这可能来自旧机器或其他体系结构吗?

Its possible that this comes from old machines, or other architectures?

推荐答案

我认为BCD在许多事情上都很有用,原因如上所述.似乎已经被忽略的一件事很明显,那就是提供一条从二进制到BCD的指令,反之亦然.这对于将ASCII数字转换为二进制进行算术运算可能非常有用.

I think BCD is useful for many things, the reasons given above. One thing that is sort of obvious that seems to have been overlooked is providing an instruction to go from binary to BCD and the opposite. This could be very useful in converting an ASCII number to binary for arithmatic.

其中一位张贴者错误地指出数字经常以ASCII格式存储,实际上,由于其效率更高,所以完成了许多二进制数字存储.将ASCII转换为二进制有点复杂.BCD介于ASCII和二进制之间,如果有bsdtoint和inttobcd指令,它将使转换变得如此容易.所有ASCII值都必须转换为二进制以算术.因此,BCD实际上在将ASCII转换为二进制的过程中很有用.

One of the posters was wrong about numbers being stored often in ASCII, actually a lot of binary number storage is done because its more efficient. And converting ASCII to binary is a little complicated. BCD is sort of go between ASCII and binary, if there were a bsdtoint and inttobcd instructions it would make conversions as such really easy. All ASCII values must be converted to binary for arithmatic. So, BCD is actually useful in that ASCII to binary conversion.

这篇关于汇编器:为什么BCD存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-12 22:49