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)?

devwebcl
  • 2,866
  • 3
  • 27
  • 46
dheart_joe
  • 11
  • 1

1 Answers1

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 - | 1235 | 00 | 03 | 01 - | 12 | 35 | 00 | 03 | 01 -1,235,000,301
divisor - | 0000 | 00 | 02 | 00 - | 00 | 00 | 00 | 02 | 00 -200
quotient + | 0006 | 17 | 50 | 01 + | 00 | 06 | 17 | 50 | 01 6,175,001
remainder - | 0000 | 00 | 01 | 01 - | 00 | 00 | 00 | 01 | 01 -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.

Erik Eidt
  • 23,049
  • 2
  • 29
  • 53