Mail Archives: djgpp/1996/10/23/12:44:27
OK, I cannot believe how grandly I screwed this one up. Here are some of the corrections I can
think of.
"A. Sinan Unur" <asu1 AT cornell DOT edu> wrote:
>Jon Slaughter wrote:
>>
>> I need some help on how to call a real mode interrupt(I think I got
>> that, though) and how to allocate a real mode buffer. Heres some code
>> that I need it for. I want to read in a sector off the floppy disk to a
>> buffer, copy the buffer to the BR struct or just read the sector
>> directly into the BR struct... any help would be appreciated. Thanks.
>>
>unfortunately, i am in the middle of something right now so i won't be
>able to comment specifically on your code. however, i am going to
>include some code that i have wrote to do netbios stuff which should
>help clarify things. the first thing you should keep in mind is that
>djgpp might leave gaps between the elements of a struct so as to be able
>align them on 4-byte boundaries. so, any structure that you will be
>using with any routines that do not expect such gaps need to be "packed"
>as in the example below:
>
>typedef struct {
>BYTE cmd __attribute__((packed));
>BYTE ret_code __attribute__((packed));
>BYTE lsn __attribute__((packed));
>BYTE ncb_num __attribute__((packed));
>WORD io_off __attribute__((packed));
>WORD io_seg __attribute__((packed));
>... etc, etc ...
>BYTE cmp_code __attribute__((packed));
>BYTE rsrv[14] __attribute__((packed));
>} NCB;
well, as somebody else pointed out in a post yesterday, you do not need to specify the
__attribute__((packed)) tag for each member of a struct, just declaring the whole struct is
enough.
>
>the precise meanings of these fields are not important. what is
>important is that each of them is followed by the
>__attribute__((packed)) tag so that there are no gaps between them.
>
>my method of passing such a structure to a dos interrupt involves (i)
>declaring a variable of of that struct's type, e.g. NCB ncb; (ii)
>allocating some dos memory for the struct; (iii) setting the members of
>the struct using the local copy and then copying that variable to the
>memory area i set up in dos memory. imho, this has the advantage of
>minimizing accesses to dos memory. the function i use to allocate dos
>memory is:
>
well, guess what, the _go32_dpmi_seginfo structure that i pass to
_go32_dpmi_allocate_dos_memory returns the segment and offset of the allocated block. I did
not know how dumb i could be but this is certainly a good indication. so, forget about the BS
function below:
>/*
> * DosMem.H
> */
>
... stuff deleted
>
>/*
> * DosMem.C
> */
>
stuff deleted ...
>
>i learned this method by examining jonipx. i think there is a link to it
>on DJ's site. a sample function that calls a DOS interrupt (int 0x5C in
>this case) could then be written as (this is an excerpt from a larger
>file so there is some more irrelevant stuff):
well, i re-examined jonipx, and jon does it exactly the way i described. that's no excuse, of
course. but since i am a beginner, i happened to trust somebody else's code more a bit too
much.
well, as regards the rest of my post, the NetBIOS installation check is still correct once you
correct the dos memory allocation function. funny thing is, it happened to work with the wrong
allocation function because i was always getting a dos memory block at the beginning of a
segment.
again, many apologies to anyone whom i may have misled. if nobody read my post, well i guess
they were right in not bothering.
>--
>*******************************************************************
> A. Sinan Unur WWWWWW
> |--O+O
> mailto:asu1 AT cornell DOT edu C ^
> mailto:sinan AT econ DOT cit DOT cornell DOT edu \ ~/
> http://www.bqnet.com/sinan/
>*******************************************************************
- Raw text -