OIC: addition


# ``add 0,1,2'' instruction:  mem[2] = mem[0] + mem[1];
# memory location 3 is ``scratch'' memory, inputs are x and y,
# in locations 0 and 1 respectively
	subz 3,3,next	# mem[3] = mem[3]-mem[3] = 0
	subz 3,1,next	# mem[3] = mem[3]-mem[1] = -y
	subz 3,0,next	# mem[3] = mem[3]-mem[0] = -y-x = -(x+y)
	subz 2,2,next	# mem[2] = mem[2]-mem[2] = 0
	subz 2,3,next	# mem[2] = mem[2]-mem[3] = -(-(x+y)) = x+y

[ CSE 80 | ACS home | CSE home | CSE calendar | bsy's home page ]
picture of bsy

bsy@cse.ucsd.edu, last updated Wed Oct 16 22:37:35 PDT 1996.

email bsy