delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/01/04:59:59

Message-ID: <D1FB30BBA491D1118E6D006097BCAE391F8B86@Probe-nt-2a.Probe.co.uk>
From: Shawn Hargreaves <ShawnH AT Probe DOT co DOT uk>
To: djgpp AT delorie DOT com
Subject: Re: Boarland 3.x to DJGPP v2
Date: Wed, 1 Apr 1998 10:58:46 +0100
MIME-Version: 1.0

Daniel Urquhart writes:
> it calls:
> regs.w.ax = 3;
>  int86(0x33,&regs,&regs);
> to get the distance the mouse has moved. It works when returning 
> positive value's but what it returns a neative vaue I get a HUGE 
> number instead (ie. < 6000).

This is because the register structure is declared as an unsigned 
data type. That doesn't cause a problem from 16 bit code (no 
conversion is needed when going from 16 bit unsigned -> 16 bit
int), but in a 32 bit environment it will be wrong because when
you read the data you are extending the return value from 16 to
32 bits. This conversion is different for signed and unsigned data,
so you need to include an explicit cast, eg. (signed short)r.x.cx;

btw. I recommend using the __dpmi_regs structure and __dpmi_int()
in preference to int86(), because int86() tries to do extra things
behind your back. Sometimes that might be useful, but it is hard
to know exactly which things it will support, so IMHO it is much
clearer and safer to always use __dpmi_int().

> Please respond by E_Mail also (this is a REALLY BIG newsgroup)
>
> --
> remove NoSpam From my E-mail to reply !

No. If you want a personal reply, please have the courtesy to give
a valid email address.


	Shawn Hargreaves.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019