Re: A89: dumb question


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

Re: A89: dumb question




In a message dated 6/20/99 8:39:58 PM Eastern Daylight Time, 
zoltan@bendor.com.au writes:

> > thanks for clearing things up...
>   >  ...more questions:  how do you know that foo is at an even location to 
> begin 
>   > with?  how do you know that (whatev) would not be an even address and 
> that 
>   > clr.whatev would not work?
>   > 
>   > does the compiler fix this?
>  
>  There are directives to force a certain alignment for the next object.
>  For example, you want to create a byte object foo and a longword
>  object bar and you want bar to be aligned on a dividable-by-four
>  address, you would do something like this:
>  
>  foo ds.b   1  ; This reserves a sigle byte storage
>      align  4  ; Forces alignment to a multiple of 4
>  bar ds.l   1  ; Reserves a long, that is, 4 bytes of storage
>  baz ds.w   1  ; Reserves a 2-byte word
>  
>  If we assume, that 'foo; happens to be at address 0x1000, your memory 
>  image will be like this:
>  
>  foo -> 0x1000 
>         0x1001 - 0x1003 are wasted
>  bar -> 0x1004 - 0x1007
>  baz -> 0x1008 - 0x1009
>  
>  The actual directives depend on the assembler (not compiler) you
>  use; you have to consult with its manual. Often they have an 'even' 
>  directive, which is equivalent to align 2.
>  
>  Regards,
>  
>  Zoltan
>  
So basically we do not have to worry about where in memory certain 
byte/work/longword objects lie because the assembler "alligns" the objects in 
memory to some even address (2 or 4)???  I do not understand how you can get 
an error when writing to an odd address if all the objects are already set to 
some even address...please explain...


Follow-Ups: