ECE243 Practice Question Website


Main Assembly Programming Input/Output Memory Computer Architecture Advanced Topics

Assembly Programming Questions





Question 36

The following is a code segment with a routine named MAIN which calls a subroutine named SUB. X, Y, and Z are addresses of three one-word memory locations.

	MAIN	.
		.
		. 			;point A
		move.w 	X,-(a7)
		move.w	Y,-(a7)
		bsr 	SUB
		move.w 	__(a7),Z 	;point D
		addi.l 	#__,a7 		;point E
		.
		.
		.

	SUB 	link 	a6,#-6
		movem.l d0-d1/a0, -(a7) ;point B
		move.w 	$08(a6),d0
		muls 	d0,d0
		move.w 	d0,-2(a6)
		move.w 	$0A(a6),d0
		muls 	d0,d0
		move.w 	d0,-4(a6)
		move.w 	$0A(a6),d0
		move.w 	$08(a6),d1
		muls 	d1,d0
		asl.w 	#1,d0
		move.w 	d0,-6(a6)
		lea 	$0A(a6),a0 
		move.w 	-2(a6),d0
		add.w 	-4(a6),d0
		add.w 	-6(a6),d0
		move.w 	d0,(a0)
		movem.l (a7)+,d0-d1/a0
		unlk 	a6 		;point C
		rts
	
Use X, Y, and Z as the name of variables. Express the function performed by SUB in the form of Z = f(X, Y).

Answer

RESULT = X2+Y2+2XY = (X + Y)2