MMIX LOGO

GO Instruction

Table of Content

Content

Author: Martin Ruckert

Situation:

The instruction GO $X,$Y,$Z (and similar GOI $X,$Y,Z) computes w=$Y+$Z and transfers controll to this address setting the location pointer λ = w. Further, mmix-doc specifies:

The two least significant bits of the address in a GO command are essentially ignored. They will, however, appear in the value of λ returned by GETA instructions, and in the return-jump register rJ after PUSHJ or PUSHGO instructions are performed, and in the where-interrupted register at the time of an interrupt. Therefore they could be used to send some kind of signal to a subroutine or (less likely) to an interrupt handler.

The assumption, that the two least significant bits of x are ignored (and might be used as flags) will make simple control-switches like the following unreliable if used repeatedly.


	LDO	$1,x
	GETA	$0,1F
	GO	$0,$0,$1
1H	JMP	Case0
	JMP	Case1
	...

For example, if x mod 4 = 2 while executing this code, the GO will jump to Case(x/4) on the first iteration, but the location pointer will no longer be a multiple of 4. Instead, we will have λ mod 4 = 2. On the second iteration, the GETA will return the address of 1H+2 in $0 and adding some x with x mod 4 = 2 will result in an (unexpected) jump to Case(x+4)/4.

After such a GO with "ignored" low order bits, even the following code will no longer work as expected:


	...
	GETA	$255,Message
	TRAP	0,Fputs,StdOut
	...
	POP	0,0	

Message BYTE	"Hello world!",0

The first few Message characters might be missing.

In summary: using GETA and GO as shown above, the "ignored" low order bits can accumulate and can lead to unexpected results.

Proposal:

The GETA instruction should mask the two low oder bits of the current location before adding.

Discussion

The potential of using the low oder bits of the location pointer to "send some kind of signal" is marginal compared to the potential hassard of accumulating low order bits. If low order bits are to be ignored, which is consistent with the use of absolute addresses in load and store instructions, then they should not have unexpected side effects.

Please help to keep this site up to date! If you want to point out important material or projects that are not listed here, if you find errors or want to suggest improvements, please send email to email