3

I'm trying to create my own WAM implementation and I'm using the instructions in Figure 2.10 of "Warren's Abstract Machine: A Tutorial Reconstruction" as a test case. However, I need to pass A1 and A2 to get_structure. But where are both variables created? put_value and put_variable both create A-variables but neither is listed in the instructions.

Charles
  • 50,943
  • 13
  • 104
  • 142
Steven Devijver
  • 2,553
  • 1
  • 22
  • 22

1 Answers1

3

Ai are "argument registers". They are part of the machine. So put_value does not create them, it fills them. Figure 2.8 on page 23 says:

put_value X_n, A_i ===  A_i <- X_n

meaning, store the value Xn in Ai.

Will Ness
  • 70,110
  • 9
  • 98
  • 181
  • The first line in Figure 2.10 is `get_structure`, it needs a register position as a second argument. However, at that time all registers are empty. My question is: which argument do I pass to `get_structure` as the second argument? – Steven Devijver Aug 15 '13 at 20:26
  • Pg. 22 says A_i are actually X_i registers. – Will Ness Aug 15 '13 at 20:27
  • All registers are empty, including the X register and HEAP. My question is: which register position to I pass when all registers are empty? – Steven Devijver Aug 15 '13 at 20:29
  • I would expect them not to be empty at that point. I'll check it. – Will Ness Aug 15 '13 at 20:30
  • That's what I would be expecting too. Maybe my problem is explained in the book but I've read chapter 2 several times and I can't figure it out. Thanks. – Steven Devijver Aug 15 '13 at 20:32
  • pg 13: *"Compiling a program term `p` is just a bit trickier, although not by much. Observe that it assumes that a query `?-q` will have built a term on the heap and set register `X1` to contain its address."* so when the compiled program is run, the registers won't be empty. -- The "value" you pass for `X1` depends on implementation, but 0 is a sensible value: X1 is the 1st of the X registers, and your implementation will know their base address, so it can use 0 as an offset for the 1st of them. Symbolically though, you just pass in `X1`. It's a position in itself. – Will Ness Aug 15 '13 at 21:56