From: | Colin Wenzel |
Date: | 04 Oct 2000 at 02:53:50 |
Subject: | Re: FIB's |
On 04-Oct-00, Gareth Griffiths wrote:
> Hello Colin,
>> Also remember, ALL DOS Structures require longword alignment.
>> Or you'll get a visit from the fellow in an orange kaftan...
>> Use AllocDosObject()
> I'm sorry, I'm a total beginner with C etc. so I've got no idea what
> you're talking about. I know that longwords are four bytes (or is it
> eight?) but I wouldn't know how to set the struct up?
> Cheers,
> GazChap.
4 bytes.....
I would suggest you have a rummage through the Autodocs,
because you are going to need to know what system calls are
available to you & you need to know what they do...
As far as DOS alignment goes, here is a bit of a history lesson
that you won't find in the Autodocs..
All addresses for structures in DOS must be
longword aligned addresses, or you will get a guru...
This goes way back when amiga dos was written in a language
called BCPL, which mapped memory in longwords not bytes.
so effectively, all BCPL addresses are normal byte addresses
divided by 4.
You will see these in the autodocs refered to as BPTR's or BSTR's
BPTR = BCPL Pointer.
(Contains a normal byte address / 4)
BSTR = BCPL String.
(Contains a string pointer address / 4 with the first byte containing
the length of the string )
So, if you need to pass a structure to ANY dos function, you must
ensure the address of the structure is on an address that is a
multiple of 4 bytes, so that when it internally converts
(byte_address >> 2) or (byte_address /4)
and then
(bcpl_address << 2) or (bcpl_address *4)
it finishes up with the same address.
AllocDosObject() returns you a block of memory that is aligned.
Although so does AllocMem(), but AllocDosObject() is supposed
to do some "extra" good DOS stuff that I have no idea what it is...
Regards
Colin Wenzel. Australia.
EMAIL: colstv@hotkey.net.au
URL: http://www.hotkey.net.au/~colstv/
ICQ: 17608330
AMIGA: 4000T, 68060/50, 150Mb RAM,
OS 3.5, Spectrum Gfx Card.
Need an Image Generator For CATV ??
http://connect.to/products
_________________________________________