| T.R | Title | User | Personal Name
 | Date | Lines | 
|---|
| 406.1 | 68000's fault right? | CADSYS::DALTON | A mind is a terrible thing | Thu Mar 02 1989 13:58 | 7 | 
|  | 
If memory serves me correctly (no pun intended), doesn't MWC have to do that
because the 68000 has to access words on word boundaries (i.e even adresses)
or you get an exception (2 bombs)? I only vaguely remember this... it's been
so long since I've done any real 68000 assembly.
KD
 | 
| 406.2 | Can't blame the compiler this time | PRNSYS::LOMICKAJ | Jeff Lomicka | Thu Mar 02 1989 14:15 | 12 | 
|  | Yes, in this case it's the MC68000, not the compiler.  MWC did the right
thing, and your code was in error.
The 68000, like the PDP-11, will "odd address trap" if you try to access
a word-sized object on an odd boundary.  This will exhibit itself on the
Atari as three bombs.
Note that if you are reading binary data from a file, you may also find
that you need to swap the bit order in the bytes that make up the int's
in your structure, since the 68000 does it backwards from the VAX and
the 8086.  On the 68000, the high order byte comes first.
 | 
| 406.3 | Guess it's time to hit the books again :-) | LEDDEV::WALLACE |  | Thu Mar 02 1989 14:28 | 6 | 
|  |     The byte ordering I new about the "odd address trap" I either did
    not know about or forgot about.
    
    Thanks for the explanation.
    
    	Ray
 | 
| 406.4 | A suggestion for your struct | SMURF::COUTU | He who will not risk, cannot win. | Thu Mar 02 1989 21:56 | 18 | 
|  |     Whenever you have to write code which is truly portable across
    machine architectures you have to worry about this. Usually people
    code for a single type of machine and so this never bites them.
    I have a suggestion for dealing with defining the structures; use
    unions instead. For example define a union which is made up of two
    different structures. One is the structure that you REALLY want with
    appropriate unnamed or dummy fields built into the right places. The
    second is a structure of unsigned chars, this is the one you use to
    read from the file with. (I suppose, come to think of it, that it
    could be most any size of element as long as it works out to exactly the
    right length.) Sure is a lot easier than having to access each element
    of the structure piecemeal!
    
    Oh, you may also run into this problem any time you store data on disk
    that was in a structure. Not all machines store data on disk in the
    same format that they use in memory. Fun eh?
    
    Dan
 | 
| 406.5 | But I thought there's a MOVEP to do it | UTRTSC::TEYEMA | Does he know where he's talkin' about, anyway | Fri Mar 03 1989 03:45 | 17 | 
|  |     Having played around a little with 68k assembly, I think there is
    a "work-around" solution for your problem, provided you can disassemble
    and re-assemble your program.
    
    The way you can handle the odd-address word access, is to change
    all apropriate 
    		MOVE.W <source>,<dest> 
    into 
    		MOVEP.W <source>,<pref.Dn register).
    I hope memory serves me well here, I think this instruction allows the
    odd-address for the source operand. About the destination, I know
    a data-register is allowed.
    
    I hope this works for you, and hope you have a good Search & Replace
    option on your editor !
    
    Casper
 |