Problem with Borland C/C++ 3.1

Greetings!


I'm in the process of putting together a simple XMS library (detecting, allocating, using, etc.) in a .C file using inline assembler... but I seem to have hit a small snag. This snag is in the form of a compiler error which doesn't seem to make ANY sense to me whatsoever. I'm using Borland C/C++ 3.1, and I'm coding in DOS.


The function I added to the .C file which caused the problem is one that calls the software interrupt handle to allocate memory... Like so:


char allocate_xms(unsigned int &handle, int ksize)

{


char rett;




asm {

mov ah,0x09 // function ah = 09 , allocate memory

mov dx,ksize // dx = the size to allocate in k

call XMS_address // calling the interrupt

les di,handle // [es:di] = handle

mov [es:di],dx // [es:di] = allocated handle

mov rett,al

}


return(rett);


}


When I try to compile this, the compiler tells me that there's an error because it expected a closing parenthesis on the char allocate_xms line... the first line of the function. It said and I quote ") expected."


I managed to determine the culprit of the problem was the & next to the handle argument. If I just take the & out and compile, it tells me that there is an incompatible use of operands and opcodes or some such... which is what I expected...


However... if I try to compile this:


char allocate_xms(unsigned int &handle, int ksize)

{

// with nothing in here

}


I still get the error that it expected a ")". If I take the & out however, like so:


char allocate_xms(unsigned int handle, int ksize)

{

}


It compiles fine.


Can somebody PLEASE tell me what's up with this error? Is the compiler being really dumb, or is it me? LOL Seriously... I'm going crazy trying to figure this out. I would appreciate it SO much if somebody could point out what I'm doing wrong...


J


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories