[comp.sys.amiga] 68k word-alignment penalty?

dillon@CORY.BERKELEY.EDU.UUCP (03/25/87)

>In article <2820@well.UUCP> ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) writes:
>>	Some system software designers, in their shorsightedness, fail to
>>provide even this basic exception handler in the OS.  Thus, the execution
>>time for an odd-address word fetch on such a system increases by several
>>orders of magnitude; from tens of seconds to almost forever. 
>
>The $64 question, then, is "does AmigaDOS do the right thing?"
>

	The 64-cent answer is, yes.  AmigaDOS properly doesn't do a #@$%
thing, And frankly, there is no reason why AmigaDOS should.  In fact, if it 
did, it might inspire sloppiness in the programmer.  I have never heard of a 
68000 OS which allows byte bounded word or long operations by installing 
an exception handler.  Can Anybody site any by name?

>>I think he phrased the question improperly.  I suspect the question he
>>really wanted to ask was whether or not the 68K optimized longword fetches
>>on longword boundaries (the 68K doesn't, I don't know about the others).
>
>No, I phrased the question correctly.  Being primarily a C hacker, and only
>having programmed the Vax-11, 6809, and Z80 in assembly, I had no idea what 
>to expect, but I didn't expect exception handling.  Pointed in the right 
>direction, I have been able to find the part of the manual that explains this.
>I assume, since instruction and word data alignment are so critical, that the
>assembler does the right thing for you when you define constant word data.

	Since the 68000 has a 16 bit data bus, longword fetches take the
same amount of time whether they are on a word boundry or a longword boundry.
A 68020, however, with its 32 bit data bus, can obviously make a longword
fetch faster on a longword boundry then on a word boundry.

	Instruction alignment on a 68K machine is very critical... instructions
must be aligned on word boundries and are always some multiple of words in
length.  Same goes with data fetches... word and long fetches must be on a
word boundry or you get an address error.

	A Vax 780, on the otherhand, doesn't care at all whether instructions
or fetches are on byte boundries.  However, it is much more efficient when
they are, and all compilers I know of keep their data on word/longword
boundries.

					-Matt

dillon@CORY.BERKELEY.EDU.UUCP (03/25/87)

>	Some system software designers, in their shorsightedness, fail to
>provide even this basic exception handler in the OS.  Thus, the execution
>time for an odd-address word fetch on such a system increases by several
>orders of magnitude; from tens of seconds to almost forever.  Some
>particularly snobbish OS designers are presumptuous enough to assume that
>such code is in error, and design the exception handler to stop your program
>dead in its tracks.  As anyone can see, this is clearly The Wrong Thing.

	Excuse me, did I hear you say 'basic'?  This 'basic' exception handler
of yours would have to fully decode the instruction in question (assuming 
68000), skip the part before the exception occured, and manually simulate the
remainder.  And your saying "designers, in their shortsightedness"?

	Get A Life!   Nobody in their right mind does an odd-address word
fetch on a 68000 on purpose!

					-Matt

grr@cbmvax.UUCP (03/25/87)

In article <8703242118.AA05186@cory.Berkeley.EDU> dillon@CORY.BERKELEY.EDU (Matt Dillon) writes:
>
>	Get A Life!   Nobody in their right mind does an odd-address word
>fetch on a 68000 on purpose!
>
>					-Matt

Hey Matt!  Cool it again - nobody needs insulting answers, no matter how silly
the question may seem to you or any other of us "experts".  Nuff said?

BTW, the 68000 is known to do some really gross things on mis-aligned word
access on some systems.  Seems it glitchs data-stobe before it gets serious
about doing an exception, causing DRAM derangement.  As far as I know, this
isn't a problem with the Amiga...


-- 
George Robbins - now working for,	uucp: {ihnp4|seismo|rutgers}!cbmvax!grr
but no way officially representing	arpa: cbmvax!grr@seismo.css.GOV
Commodore, Engineering Department	fone: 215-431-9255 (only by moonlite)

rokicki@rocky.UUCP (03/25/87)

grr@cbmvax.cbm.UUCP (George Robbins) writes:
> BTW, the 68000 is known to do some really gross things on mis-aligned word
> access on some systems.  Seems it glitchs data-stobe before it gets serious
> about doing an exception, causing DRAM derangement.  As far as I know, this
> isn't a problem with the Amiga...

This is a known `feature' of the 68000, well documented in the
manual.  If memory serves, it drops address strobe, and then raises
it without dropping either data strobe.  Any system which does not
have the necessary logic to deal with this is an improperly designed
system and its designers should be taken out and summarily shot.

tenney@well.UUCP (03/27/87)

I've been waiting for someone that knows the details to post an 
answer, but seeing none here goes:  Sorry, but there is no way
that an interrupt routine can recover from such a trap!  Long
ago, it was discovered that when a byte address was used on a
mem-write, the byte after the one in question would be trashed
before the trap was taken.  That is my recollection, perhaps it
was on a read too, but that wouldn't make sense.  Doesn't anyone
else remember the exact situation?
-- Glenn Tenney 
UUCP: {hplabs,glacier,lll-crg,ihnp4!ptsfa}!well!tenney
ARPA: well!tenney@LLL-CRG.ARPA        Delphi and MCI Mail: TENNEY
As Alphonso Bodoya would say... (tnx boulton)
Disclaimers? DISCLAIMERS!? I don' gotta show you no stinking DISCLAIMERS!

ewhac@well.UUCP (03/28/87)

In article <8703242118.AA05186@cory.Berkeley.EDU> dillon@CORY.BERKELEY.EDU (Matt Dillon) writes:
>>	Some system software designers, in their shorsightedness, fail to
>>provide even this basic exception handler in the OS.  Thus, the execution
>>time for an odd-address word fetch on such a system increases by several
>>orders of magnitude; from tens of seconds to almost forever.  Some
>>particularly snobbish OS designers are presumptuous enough to assume that
>>such code is in error, and design the exception handler to stop your program
>>dead in its tracks.  As anyone can see, this is clearly The Wrong Thing.
>
>	Excuse me, did I hear you say 'basic'?  This 'basic' exception handler
>of yours would have to fully decode the instruction in question (assuming 
>68000), skip the part before the exception occured, and manually simulate the
>remainder.  And your saying "designers, in their shortsightedness"?
>
>	Get A Life!   Nobody in their right mind does an odd-address word
>fetch on a 68000 on purpose!
>
>					-Matt

	Woah!  Hey, wait a minute!  Did no one notice the first line in the
posting which read:

[ Please set your local SIMLEY_FACE bit when reading this article. ]

	It was a satire!  I know that no one does odd address word fetch on
purpose.  I thought the article was outrageous enough that no one would
possibly take it seriously.  Guess I'll have to improve my satire skills.

	He asked if there was a performance penalty for doing odd word
access, and I said Yes.  The program crashes.  That strikes me as a
performance degradation, how about you?

	Maybe I should have put SATIRE_ON at the top of the article...

_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 ________		 ___			Leo L. Schwab
	   \		/___--__		The Guy in The Cape
  ___  ___ /\		    ---##\		ihnp4!ptsfa!well!ewhac
      /   X  \_____    |  __ _---))			..or..
     /   /_\--    -----+==____\ // \  _		well ---\
___ (   o---+------------------O/   \/ \	dual ----> !unicom!ewhac
     \     /		    ___ \_  (`o )	hplabs -/       ("AE-wack")
 ____ \___/			     \_/
	      Recumbent Bikes:			"Work FOR?  I don't work FOR
	    The _O_n_l_y Way To Fly!		anybody!  I'm just having fun."

tim@ism780c.UUCP (04/02/87)

In an article Matt Dillon writes:
> I have never heard of a 68000 OS which allows byte bounded word or
> long operations by installing an exception handler.  Can Anybody
> site any by name?

An odd address trap is just like a bus error as far as restartablity
is concerned.  Only a fool would try it on anything earlier than
the 68010.  On the other hand, there are a lot of fools...
-- 
Tim Smith			"And if you want to be me, be me
uucp: sdcrdcf!ism780c!tim	 And if you want to be you, be you
Compuserve: 72257,3706		'Cause there's a million things to do
Delphi or GEnie: mnementh	 You know that there are"