[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::amiga_v1

Title:AMIGA NOTES
Notice:Join us in the *NEW* conference - HYDRA::AMIGA_V2
Moderator:HYDRA::MOORE
Created:Sat Apr 26 1986
Last Modified:Wed Feb 05 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:5378
Total number of notes:38326

2620.0. "68000 Addressing Limitation ?" by ADOVAX::MCGHIE () Sun Jun 04 1989 08:03

    Hi,
    
    in the process of trying to convert a datafile using BenchMark Modula-2
    I have run into an irritation.
    
    It seems the language insists on even alignment on word and longword
    structures. In fact the manual even goes as far as to say that arrays
    and records are rounded up to an even number of bytes.
    
    So if I have a structure like the following :-
    
    my_record = RECORD
    	my_string: ARRAY [ 1..15 ] OF CHAR;
    	my_int	: INTEGER;
    	my_char	: CHAR;
    	int2	: INTEGER;
    END;
    
    What I end up with, is there is two filler bytes included in the
    structure, one after my_string and one after my_char.
    
    The manual indicates that WORD and LONGWORDs are even byte aligned due
    to limitations in the 68000 architecture. Is this in fact correct ?
    
    If it is then the Modula-2 structures would be compatible with Amiga C
    compiler structures etc.
    
    Have I made the problem (if it is that) clear ?
    
    thanks
    	Mike
T.RTitleUserPersonal
Name
DateLines
2620.1Alignment countsNSSG::SULLIVANSteven E. SullivanSun Jun 04 1989 22:4512
Hi Mike!

Been real busy lately...

    Anyway,  here  is  the  answer:  yes.  The  68000/10 require word
alignment of 16 bit and 32 bit quantities. The 68020/30 do not.  That
is  not  to  say  that alignment does not affect performance with the
020/030. It definitely does and having data aligned will  payback  in
definite performance advantages as well as 68000/10 compatibility.

	Thanks,
		-SES
2620.2exitADOVAX::MCGHIESun Jun 04 1989 23:499
    Nice to hear from you,
    
    Umm, I presume that means all languages and structures currently used
    by the Amiga have the problem I outlined in .0 ?
    
    thanks 
    	Mike
    
    
2620.3CANAM::SULLIVANSteven E. SullivanMon Jun 05 1989 13:473
Yup!

	-SES
2620.4manx c different?ALASKA::QUIRICIMon Jun 05 1989 15:4520
    I have manx C and i was under the impression that the compiler will NOT
    insert alignment padding within a structure. That is, for example, in
    the structure
    structure test
    {
    	char field_1;
    	long field_2;
    }
    
    field_2 will in fact be offset one character after the start of the
    structure. I don't know if the compiler will automatically align
    any structure at word or long addresses, but even it did that would
    certainly not help in the above case.
    
    i do know, as was pointed out in previous replies, that the 68000
    requires longs to be long-aligned, etc.
    
    is my information about manx C incorrect?
    
    ken
2620.5more on manx cALASKA::QUIRICIMon Jun 05 1989 15:579
    actually, now that i think about it, it would have to align field_2 at
    a long, otherwise the generated code would bomb with an addressing
    exception (?). Unless it does something more tricky?
    
    sorry for the possibly false lead.
    
    (feel stupid, or at least ignorant).
    
    ken
2620.6Avoid odd addressesTLE::RMEYERSRandy MeyersFri Jun 09 1989 21:4515
Re: .4, .5

The 68000 does require two and four byte objects to be aligned on a
word boundary.  If they are not (if the address is odd), you do get
a Guru 3 (alignment error).

As Steve pointed out a few replies back, longs only need to be aligned
on a word boundary, not a longword boundary.  This makes sense if you
think about it:  The 68000 is really a 16 bit machine.  When it fetches
a 32 bit value, it really fetches two 16 bit values and pastes them together.

There are some things required to be on a longword boundary, but this
is a software, not a hardware issue.  The BCPL guts of Amiga DOS
stores pointers as normal pointers divided by four.  The is because
of some BCPL brain damage, and has nothing to do with the 68000 proper.
2620.7exitADOMV1::MCGHIESun Jun 18 1989 23:024
    Thanks Randy,
    
    regards
    	Mike