Hi!

13-Июн-2006 23:35 [EMAIL PROTECTED] (Blair Campbell) wrote to
[email protected]:

BC> Well, if it's ever ported to OW, it's probably best to use inline
BC> assembler anyways  :-)
>> BC> +    _AH = 0x0F;
>> BC> +    geninterrupt( 0x10 );
>> BC>      _AH = 0x02;
>> BC>      _DH = ( y - 1 );
>> BC>      _DL = ( x - 1 );
>> BC>      geninterrupt( 0x10 );
>>      Perfect. (Except, that there used TC/BC-related extension, not portable
>> to other compilers.)

     Not necessary:

void goxy (byte x, byte y) {
  union REGS r;
  r.h.ah = 0x0F; int86 (0x10, &r, &r);
  r.h.dh = y - 1;
  r.h.dl = x - 1;
  r.h.ah = 0x02; int86 (0x10, &r, &r);
}

This not much worser (in size sense) and requires no _any_ change, when
porting to other compilers. The more important, there you shouldn't worry,
that register, which you initialize previously, will be injured by next
expressions! Try this:

_AX = 1;
_DX = x / y;

and watch _AX value.

     On the other side, there is alternative approach to call interrupts:

union REGS reg;
struct SREGS sreg;
#define R_AX reg.x.ax
#define R_AL reg.h.al
...
#define R_CFLAG reg.x.cflag
#define R_ZFLAG (reg.x.flags & 0x40)
...
unsigned callint (byte n) { return int86x (n, &r, &r, &sreg); }
...
void goxy (byte x, byte y) {
  R_AH = 0x0F; callint (0x10);
  R_DH = y - 1;
  R_DL = x - 1;
  R_AH = 0x02; callint (0x10);
}

This code isn't much worser (in size sense), than inline assembler (or using
register pseudo-variables), but noticeably portable. On the other side, you
may add:

#ifdef __TURBOC__
# define R_AX _AX
# define R_AL _AL
...
# define R_CFLAG (_FLAGS & 1)
# define R_ZFLAG (_FLAGS & 0x40)
...
# define callint(n) (geninterrupt (n), _AX)
#else
  union REGS reg;
  struct SREGS sreg;
# define R_AX reg.x.ax
# define R_AL reg.h.al
...
# define R_CFLAG reg.x.cflag
# define R_ZFLAG (reg.x.flags & 0x40)
...
  unsigned callint (byte n) { return int86x (n, &r, &r, &sreg); }
#endif

     And thus optimize especially for TC/BC.


_______________________________________________
Freedos-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to