ECE243 Practice Question Website


Main Assembly Programming Input/Output Memory Computer Architecture Advanced Topics

Assembly Programming Questions





Question 31

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
	
Assume at point A, the top of the processor stack is at address TOSA. After the instruction at point B, what are the data items on top of TOSA and their sizes? (fill in the memory table)
Data(words) Address
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
  TOSA

Answer

Data(words) Address
   
   
   
d0, d1, a0  
d0, d1, a0  
d0, d1, a0  
d0, d1, a0  
d0, d1, a0  
d0, d1, a0  
local vars  
local vars  
local vars  
old a6 <-a6
old a6  
return adr  
return adr  
Y  
X  
  TOSA