gpt4 book ai didi

assembly - 什么是十六进制减法中的借位? (集会)

转载 作者:行者123 更新时间:2023-12-04 12:26:33 26 4
gpt4 key购买 nike

快速提问,我正在阅读 Richard C. Detmer 编写的题为“80x86 汇编语言和计算机体系结构简介”的教科书,第 21 和 22 页谈到了借用的概念,但它并没有真正描述什么确实如此。以下是正文:

In a computer, subtraction a - b of numbers a and b is usually performed by taking the 2's complement of b and adding the result to a. This corresponds to adding the negation of b. For example, for the decimal subtraction 195 - 618 = -423,

00C3 - 026A

is changed to addition of FD96, the 2's complement of 026A.

00C3 + FD96 = FE59

The hex digits FE59 represent -423. Looking at the previous addition in binary, you have

0000 0000 1100 0011 + 1111 1101 1001 0110 = 1111 1110 0101 1001

Notice that there was no carry in the addition. However, this subtraction did involve a borrow. A borrow occurs in the subtraction a - b when b is larger than a as unsigned numbers. Computer hardware can detect a borrow in subtraction by looking at whether a carry occurred in the corresponding addition. If there is no carry in the addition, then there is a borrow in the subtraction. If there is a carry in the addition, then there is no borrow in the subtraction. (Remember that "carry" by itself means "carry out.")

Here is one more example. Doing the decimal subtraction 985 - 411 = 574 using word-length 2's complement representations,

03D9 - 019B

is changed to addition of FE65, the 2's complement of 019B.

03D9 + FE65 = 1023E

0000 0011 1101 1001 + 1111 1110 0110 0101 = 1 0000 0010 0011 1110

Discarding the extra 1, the hex digits 023E represent 574. This addition has a carry, so there is no borrow in the corresponding subtract.

什么是减法借位?我想当例如 00C3 - 026A 时,A 大于 3,所以我们必须从相应的 C 中“借用”,使其成为 B 并使其现在成为 13(基数 16)减去 A。我们可以做到,但是发生了“借”。在这个特定的例子中,确实发生了对本书上下文的借用。但是当我们看下一个例子时,他们给了我们 03D9 - 019B,B 比 9 大,所以我们必须从 D 中“借用”,使它成为 C 并使 9 成为 19(以 16 为底)减去 B。那我们可以做到,并且发生了“借用”,但书上说没有发生借用。

什么是借用?我知道你知道是否发生了加法中是否发生了进位但是做原始减法,什么是真正的借位。我什么时候可以确定是否发生过?

例如,您知道发生进位是因为有一个额外的十六进制数字。长度超出了您的两个十六进制数字的长度(希望留在其中的长度)。

谢谢。

-丹

最佳答案

在书中,他所说的借用不同于传统意义上的借用。他说只有当 ENTIRE 减法的结果为负数(换句话说,b > a)时才会发生借位,而不一定是个别数字的结果。

关于assembly - 什么是十六进制减法中的借位? (集会),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21863607/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com