Hi!

11-Июн-2006 19:56 [EMAIL PROTECTED] (Blair Campbell) wrote to
[email protected]:

BC> simple macros can be defined to access low and high bits of CPU
BC> registers.  If you feel like making some for me, feel free  :-) .
 >> >> BC> +        displayString(TEXT_MSG_VER_DOS_VERSION, regs.r_ax & 0xFF,
 >> >> regs.r_ax >> 8);
 >> >>       intr() is bad, because REGPACK doesn't allows to access registers
 >> >> parts
 >> >> (for example, AL/AH), and this causes noticeably inefficient and 
unreadable
 >> >> code. Why not use int86(), which you already used in other places?

      First, macros you may get from portab.h in (newer) kernels:

______________O\_/_________________________________\_/O______________
#define lonibble(v) (0x0f & (v))
#define hinibble(v) (0xf0 & (v))

#if CHAR_BIT == 8
# define lobyte(v) ((UBYTE)(v))
#else
# define lobyte(v) ((UBYTE)(0xff & (v)))
#endif
#define hibyte(v) lobyte ((UWORD)(v) >> 8u)

#if USHRT_MAX == 0xFFFF
# define loword(v) ((unsigned short)(v))
#else
# define loword(v) (0xFFFF & (unsigned)(v))
#endif
#define hiword(v) loword ((v) >> 16u)

#define MK_UWORD(hib,lob) (((UWORD)(hib) <<  8u) | (UBYTE)(lob))
#define MK_ULONG(hiw,low) (((ULONG)(hiw) << 16u) | (UWORD)(low))
[...]
#define MK_PTR(type,seg,ofs) ((type FAR*) MK_FP (seg, ofs))
_____________________________________________________________________
               O/~\                                 /~\O

Second, macros here can't fix inherent ineffectiveness (and lesser
readability) of REGPACK/intr() usage. Even with these macros

displayString (TEXT_MSG_VER_DOS_VERSION, lobyte (regs.r_ax),
                                          hibyte (regs.r_ax));

is less readable (and often less effective), than

displayString (TEXT_MSG_VER_DOS_VERSION, regs.r.h.al, regs.r.h.ah);


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

Reply via email to