assemblyknuthtaocp

What is the meaning of "ENT1 *" in TAOCP MIX assembly language?


In the book The Art of Computer Programming Volume 1, third edition, I'm having some hard time understanding the meaning of the following MIX assembly language instruction: ENT1 *, which appears on page 189 of the book.

(p.189) For example, if we wanted to make the calling sequence for MAXN be

     JMP  MAXN
     CON  n

then the subroutine could be written as follows:

MAXN STJ  *+1
     ENT1 *

What I've figured out so far is that the following line

MAXN STJ  *+1

stores the address of the memory where the constant n is stored to the [0:2] field of the memory location where the instruction ENT1 * is stored.

Therefore, I'm guessing here that the following line

     ENT1 *

is supposed to load the value of [0:2] field of the memory location where the instruction ENT1 * is stored to register I1.

However, the meaning of asterisk(*), as stated in the text book is:

(p.146) An asterisk (read "self") refers to the location of the line on which it appears.

So, shouldn't ENT1 * just store the address of the memory location where the instruction ENT1 * is stored to register I1?


Solution

  • Short Answer

    The point that I missed was that the asterisk(*) being the value of the current location is worth acknowledging only at the time of assembling. Since MIX is an assembly language that modifies the instruction itself, the value that is stored in the I1 register is determined at run-time.

    So in this case, the asterisk(*) in ENT1 * has no meanings. It is even possible to change * to any value, since the value that is stored in the I1 register will be determined by the previous instruction: STJ *+1.

    Verification with MIX Builder

    I've assembled the following MIX assembly language code with MIX Builder on Windows 10 downloaded from here.

          ORIG 3000
    BEGIN JMP  MAXN
          CON  100
    MAXN  STJ  *+1
          ENT1 *
          LD3  0,1
          HLT
          END  BEGIN
    

    After assembling, the result is:

    enter image description here

    We can check that the instruction in line 5, ENT1 *, has the current memory location 3003 stored on the [0:2] field.

    After executing line 4, the [0:2] field of line 5 changes to 3001, the memory location where the constant 100 is stored:

    enter image description here

    Therefore, after executin line 5, the value 3001 (not 3003) will be stored in the I1 register:

    enter image description here

    Note that combining the byte values 46 and 57 in the I1 register results in 3001(= 46 * 64 + 57), i.e. they are base 64 values.