英文:
Arithmetic operations in donald knuth's Mix assembly language 1.3.1
问题
我一直在阅读唐纳德·克努斯的《编程的艺术》,第一卷,其中MIX用作汇编语言。在克努斯讨论MIX中的算术操作的部分,我不理解减法、乘法和除法操作是如何进行的。
例如,教材上写着:
寄存器A具有以下的字码:-| 1235 | 0 | 3 | 1
,而一个内存单元M有以下的字码:-| 0 | 0 | 0 | 2 | 0
。
书中表示执行DIV 100的结果是:rA(+ | 0 | 617 | ? | ?)
,rX(- | 0 | 0 | 0 | ? | 1)
。
有人能帮我解释一下吗?
根据我的了解,结果应该是rA(+ | 0 | 617 | 5 | 1)
,rX(- | 0 | 0 | 0 | 1 | 1)
。
英文:
I have been reading Donald Knuth's The Art of Programming, Volume 1, in which MIX is used as the assembly language. In the section where Knuth talks about arithmetic operations in MIX, I didn't understand how the subtraction, multiplication and division operations are carried out.
For example, the text book has this:
register A has the following word code: -| 1235 | 0 | 3 | 1
and a memory cell, say M, has the following word code: -| 0 | 0 | 0 | 2 | 0
.
The book says on performing DIV 100 the result is: rA(+ | 0 | 617 | ? | ?)
, rX(- | 0 | 0 | 0 | ? | 1)
.
Can anyone help me with this?
As I know, should it be rA(+ | 0 | 617 | 5 | 1)
, rX(- | 0 | 0 | 0 | 1 | 1)
?
答案1
得分: 2
I don't think you have enough setup information here for the given DIV instruction, plus you're mixing 4-part word form and the 5-part word form, but let's focus on dividing:
- dividend = -1235000301
- divisor = -200
- -1235000301 / -200 = 6175001.505
- quotient = 6175001
- remainder = -101 = 0.505 * -200
Component | MIX 4-part Decimal | MIX 5-part Decimal | Numeric Value | |
---|---|---|---|---|
dividend | -1235000301 | -1235000301 | -1,235,000,301 | |
divisor | -00000200 | -00000200 | -200 | |
quotient | +0006175001 | +0006175001 | 6,175,001 | |
remainder | -00000101 | -00000101 | -101 |
In a shorter version of the above word forms, strip leading zeros — e.g. 1 means 01 — but don't forget to include leading zeros to obtain the full and proper numeric value.
英文:
I don't think you have enough setup information here for the given DIV instruction, plus you're mixing 4-part word form and the 5-part word form, but let's focus on dividing:
- dividend = -1235000301
- divisor = -200
- -1235000301 / -200 = 6175001.505
- quotient = 6175001
- remainder = -101 = 0.505 * -200
Component | MIX 4-part Decimal | MIX 5-part Decimal | Numeric Value | |
---|---|---|---|---|
dividend | `- | 1235 | 00 | 03 |
divisor | `- | 0000 | 00 | 02 |
quotient | `+ | 0006 | 17 | 50 |
remainder | `- | 0000 | 00 | 01 |
In a shorter version of the above word forms, strip leading zeros — e.g. 1 means 01 — but don't forget to include leading zeros to obtain the full and proper numeric value.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论