Page 1 of 1
address alignment
Posted: Sat Mar 29, 2008 10:26 am
by devel
Hi,
might be a newbie question but how to locate a 6 bytes structure at an odd word address i.e.
address mod 4 equals to 2? An example in C would be very helpful, thnx.
regards,
devel.
Posted: Sat Mar 29, 2008 11:09 am
by 01000101
I am confused by your question. Do you want to know how to find a 6-byte structure or are you wondering about its location relative to an 'odd' linear address?
Posted: Sat Mar 29, 2008 11:17 am
by devel
01000101 wrote:I am confused by your question. Do you want to know how to find a 6-byte structure or are you wondering about its location relative to an 'odd' linear address?
how to put 6bytes structure at an odd word address.
Posted: Sat Mar 29, 2008 11:29 am
by cyr1x
Code: Select all
memcpy(ptr-(ptr%4), ptr, lenght);
I think this should work.
Posted: Tue Apr 01, 2008 12:55 pm
by bewing
Add a 2 byte word to the beginning of the structure, and put it at a normal address -- then pass the pointer to the second entry in the structure.
Re: address alignment
Posted: Wed Apr 02, 2008 3:49 am
by os64dev
devel wrote:how to locate a 6 bytes structure at an odd word address i.e.
address mod 4 equals to 2? An example in C would be very helpful, thnx.
Code: Select all
struct pseudo_ptr {
unsigned short dummy;
unsigned short segment:
unsigned long address;
};
an example where it is used. struct needs to be packed btw.