Computer Architecture - Instruction Sets and Addressing Modes Questions

Associate
Joined
13 Jan 2007
Posts
2,424
Location
Belfast,Northern Ireland
I can nail this entire section except for the last question everytime, I could probably memorise similar questions and adapt my answer but im a gimp and like to know what im doing and how things work :)

Anyway heres two past paper questions including the answers, could someone be kind enough as to explain this in a step by step process so I actually understand how the answers are coming about? Its an MC68k processor if that helps anyone thinking WTF

Code:
What are the hexadecimal values in address registers A1 and A2 and memory locations $2000 to $2007 after executing the following subroutine once? 

		ORG  	$2000

	alpha	DS.W	2
	beta	DS.W	1
	gamma	DC.W	$1A43

	subroutine	LEA	alpha,	A1
		MOVE.L 	#$29, 	(A1)+
		LEA	beta, 	A2
		MOVE.W	(A1), 	(A2)+
		RTS
		[5 marks]

A1	2002
A2	2006
2000 	00
2001 	00
2002 	00
2003 	29
2004 	00
2005 	29
2006 	1A
2007 	43

Code:
(d)	What are the hexadecimal values in address registers A0 and A1 and memory locations $400 to $407 after executing the following subroutine? 

		ORG  	$400
		DS.B	2
		DC.B	9,4,2,7,3,10

	subroutine	LEA	$400, A0
		LEA	$404, A1
		MOVE.B	(A1)+, (A0)+
		MOVE.B	(A1)+, (A0)
		MOVE.B	(A1), (A0)+
		RTS
	[6 marks]

A0	$402
A1	$406
$400	$02
$401	$03
$402	$09
$403	$04
$404	$02
$405	$07
$406	$03
$407	$0A (A0, A1 1 mark each, others 0.5 marks each)
 
Ive only use assembler in pics so i wont be much help, in order to answer this question you need the assembler instruction set for the MC68k processor.

download it and lookup the functions.
 
Last edited:
I dont think i need it for these types of questions? The answers given after the [6 marks] bit or whatever marks it is. Its basically just a simple trace but I dont understand exactly how its working as they seem to jump a bit around the place
 
I dont think i need it for these types of questions? The answers given after the [6 marks] bit or whatever marks it is. Its basically just a simple trace but I dont understand exactly how its working as they seem to jump a bit around the place

Been a while since I did any 68k asm.. Are the
Code:
alpha	DS.W	2	; reserve 2 words of memory for alpha

located straight after ORG $2000 (Program start location)? So

Code:
	subroutine	LEA	alpha,	A1		; load effective address of alpha into A1    A1 = Address of alpha A1 = 2003 
		MOVE.L 	#$29, 	(A1)+			; Moves 29 hex into where the address of A1 points (2003 = $29) then post increment address

So far..

Im unsure where in memory the constants/reserved space get allocated.. should be easily to follow after that.
 
Hmm we did 68000 assembler as part of my degree, infact I have the book from that right behind me.. unfortunately I've just popped on for a coffee break before I get stuck into performance reviews.
 
crikey, assembler, I'm rusty

first question:

ORG sets the origin of the memory address to 2000?

DS.W declares memory for variables (W being a word? two bytes)
DC.W defines and declares a constant (size is one word? 1A43 in hex)

two registers A1 and A2

so memory is structured like this: (?)

2000 alpha
2001 alpha
2002 alpha
2003 alpha
2004 beta
2005 beta
2006 constant gamma first byte (most significant) (1A) so this must be big-endian
2007 constant gamme second byte (43)

this doesnt look quite right to me, remember im rusty :) if you can give me feedback shicky it might jog my memory!
 
Been staring at this stuff too long and really not catching onto it, need to get my focus back.

Yes ORG sets the starting address to whatever number is beside it.
DS stands for Define Storage so DS.W 2 means a space is saved $2000-2002 I believe?
DC is Define Constant as you rightly pointed out. In this case it'll be placed in $2005-$2006? Only in the beginning of course.

MOVE.L
MOVE.W
MOVE.B is basically placing one thing in another with Longword, word or byte format

Registers beginning with A are address registers also if you werent aware but im sure you were
 
Bah had it sorted there now but that second question has thrown me off

Fully get it now, never worry! Thanks for the help though
 
Last edited:
Back
Top Bottom