From: Andrew Crabtree Message-Id: <199704102214.AA151680495@typhoon.rose.hp.com> Subject: Re: Ada, C and interrupts To: rchampre AT ada DOT info DOT unlp DOT edu DOT ar (Raul Champredonde) Date: Thu, 10 Apr 1997 15:14:55 PDT Cc: djgpp AT delorie DOT com In-Reply-To: <199704102011.RAA14915@ada.info.unlp.edu.ar>; from "Raul Champredonde" at Apr 10, 97 5:11 pm > I programed some functions in `C' to do interrupts and use NETBIOS service routines. > My `C' program run well. Was your C program written originally in DJGPP or a real mode compiler like Turbo C. It looks like the latter, in chich case you will need to rewrite in DJGPP to use with 32 bit ADA. > I want to call a NETBIOS functions, previously loaded in the interrupts vector, > > *Q1* How do I get the segment to put into the `ES' register? > > *Q2* How can I obtein the buffer's address when I alloc memory using `malloc' function > since it returned me an address formated in 20 bits (lineal address) and I need > an adress formated like this: segment:offset (32 bits). NETBIOS functions > requests ES and BX to be setted. 20 bit addresses only in real mode. Assuming you port your C code to DJGPP then use dpmi_allocate_dos_memory and __dpmi_int and dosmemput dosmemget. This is probably easiest. The faq does a good job of explaining this, but if you are still confused send private email and I wil give you code which does just what you are asking. > *Q3* How can I run ada95 in real mode?. Exist any way to run ada95 in non protected mode? No idea. If its part of the 32 bit gnu stuff I doubt its possible, > **1st. A** : Use `int86x', then just put the address of your buffer into the register Don't do this. NetBIOS is not one of the special functions. > **2nd. A** : Call `__dpmi_int,' and then put into that register pair an address > of some buffer in *conventional* memory (in the first 1 MByte).The buffer's size > that I need is 64 bytes only. Nope. If you just malloced the memory in DJGPP the it doesn't exist in conventional memory. Thats what the allocate_dos_mem is for. > **3rd. A** : I found a method for transform lineal address to segment-offset address: > OFFSET = (LINEAL_ADDRESS)&000Fh > SEGMENT = (shift_right(LINEAL_ADDRSS,4))&FFFFh Since you used a 32 bit offset into your selector, and not a 20 bit linear this won't work (would in Turbo C though I think). > **4th. A** : Use the transfer buffer. That buffer is used for all DOS/BIOS > services supported by DJGPP, and it resides in conventional memory. This could work but I would use your next choice. > **5th. A** : Allocate my own buffer in conventional memory with a call to the > `__dpmi_allocate_dos_memory' library function. It returns me the segment of > the allocated block (the offset is zero). > > * OK, I've the offset and the segment but when I intended write into the buffer > I get "Segmentation Violation and "General Protection Fault". Are you using dosmemput to move data into your conventional mem buffer? Try that. HTH Andrew