• Please review our updated Terms and Rules here

Another BASM question if anyone knows it

alank2

Veteran Member
Joined
Aug 3, 2016
Messages
2,264
Location
USA
I have a function that returns a long which is dx:ax. I am calling DOS 42h to set/get the file position and I already have dx:ax prepared by that function call.

Other functions I've done just return AX with a simple:

return _AX;

but when I am trying to return a long, I can't do a return _DX:_AX;

I can do a return with no argument which works, but generates a compiler warning because it expects a long.

I've ended up doing this which works, but I don't love it:

unsigned dx, ax;

<code>

ax=_AX;
dx=_DX;
return ((long)dx<<16) | ax;

Maybe there is nothing better...
 
You can probably do something like this (of the top of my head):
Code:
long myfunc( ... ) {
  long handle;

  ...
  asm mov [word ptr handle + 0], ax
  asm mov [word ptr handle + 2], dx
  ...

  return handle;
}
 
Back
Top