Re: A89: Starting out assembly, need help


[Prev][Next][Index][Thread]

Re: A89: Starting out assembly, need help




>In a message dated 12/2/98 7:44:46 PM Pacific Standard Time,
>nlmueller@students.wisc.edu writes:
>
>>> No, it's just like a function but instead of branching the function is
>>> pasted in place.  Your program will be bigger but will run faster.  Because
>>> of the early pipelining on the m68k, you waste 4 instructions when you
>>> branch.  If you have a function that you use a lot and you don't care about
>>> size, using macros can really speed up execution.
>>>
>>> 	--Nate
>
>
>Do you mean four words?  That's a lot for a simple branch instruction.  In the
>programmer's guide from Motorola, it says that some instructions may take up
>to 11 words!
>
>Daniel Imfeld

No, the m68k is executing five instructions at once.  This way, on a 10 MHz
chip it takes 5 cycles to finish one instruction, but only 1 cycle to
finish the next instruction.


1	2	3	4	5	6	7	8	9	10
IF	ID	EX	MA	WB
	IF	ID	EX	MA	WB
		IF	ID	EX	MA	WB
			IF	ID	EX	MA	WB
				IF	ID	EX	MA	WB
					IF	ID	EX	MA	WB

IF -- Instruction fetch:  The processor reads the pc and finds the next
instruction.
ID -- Instruction decode:  Look at the instruction and figure out what it is
EX -- Execute:  If it is an add, do the add.  If it is a load or store do
the effective memory calculation
MA -- Memory access:  If it is a load or a store, access memory.  Otherwise
do nothing
WB -- Write the calculated value back to the destination register

Now lets say the first instruction is a branch.  Since the correct value of
the pc isn't written until cycle 5, you have to through out the next 4
instructions and start with the correct "next" instruction at cycle 6.
"Next" being the next instruction in the flow of the program, not the next
linearly in memory.

If you have a common function it is better to write it as a macro to save
time.  Espically if you call a non-recursive function from inside a
recursive one.  Unfortunatly, the calculator doesn't have the memory of a
computer so macros aren't really that useful except when called inside a
recursive function.

	--Nate


References: