MIX中的除法如何工作? [英] How does division work in MIX?

查看:134
本文介绍了MIX中的除法如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我MIX的除法(来自Knuth的TAOCP)是如何逐字节进行的吗?

Can someone explain to me how division in MIX (from TAOCP by Knuth) works on a byte-to-byte basis?

rA = |-| . . . .0| 

rX = |+|1235|0|3|1|

存储位置1000包含|-|0|0|0|2|0|.

The memory location 1000 contains |-|0|0|0|2|0|.

执行操作时

DIV 1000

寄存器变为

rA = |+|0|617|?|?|

rX = |-|0|0|0|?|1|

现在我理解了rArX上的符号,但是rAX的字节以什么顺序填充以及完成了哪些除法?

Now I understand the signs on rA and rX, but in what order are the bytes of rAX filled and which divisions are done?

如果DIV 1000导致每一位除以2,那么我会期望

If DIV 1000 leads to every bit divided by 2, then I would expect

rAX = |+|617|0|1|0|-|0|1|0|1|1| 

,其中rA包含除法结果,rX余数(从右侧填充).

in which rA contains the division results and rX the remainders (filled from the right side).

我很可能在这里遗漏了一些东西,而Knuth似乎认为我应该能够自己弄清楚(因此,我也没有得到有关该问题的10级问题),但是有人可以在这里帮我吗?

I'm probaly missing something here, and Knuth seems to think I should be able to figure it out myself (hence the level 10 questions about it, which I also don't get), but could someone help me out here?

推荐答案

所以我有点想通了.

如果手动进行除法,将字节转换为一个数字,您将得到-210,501,825(如果您使用的是最小的字节-在Knuths书中为6位(!)).将其除以-128,这是使用相同字节大小的位置1000中的值.

If you do the division by hand, by converting the bytes into a single number you will get -210,501,825 (if you're using the smallest kind of byte - which is 6 bits (!) in Knuths book). Divide this by -128, which is the value in location 1000 using the same bytesize.

商为1644545,余数为65,由于两个数字均为负,因此该符号为正.如果您将1644545存储在rA中,并将65存储在rX中,则会得到

The quotient is 1644545, the remainder 65, the sign will be postive since both numbers are negative. If you store 1644545 in rA and 65 in rX, you will get

|+|0|6|17|32|01|
|-|0|0|0|1|1|

使用最小的字节大小(可容纳64个数字).由于Knuth在他的示例中从不假定特定的字节大小,因此rX带有许多问号. rX的符号始终是rA的先前符号.

using the smallest bytesize (which holds 64 numbers). Since Knuth never assumes a particular bytesize in his examples, rX has a number of question marks. The sign of rX is always the previous sign of rA.

我使用了非常方便的 MixEmul 实用程序MIX的寄存器.这是在.NET中完成的非常漂亮的MIX实现

I used the very handy MixEmul utilty to play around with the registers of MIX. This is a pretty nice MIX implementation done in .NET

这篇关于MIX中的除法如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆