Hi!
Bart, what wrong with next macroses?
______________O\_/_________________________________\_/O______________
#include <limits.h>
#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 ((v) >> 8u)
#if USHRT_MAX == 0xFFFF
# define loword(v) ((unsigned short)(v))
#else
# define loword(v) (unsigned short)(0xFFFF & (v))
#endif
#define hiword(v) loword ((v) >> 16u)
_____________________________________________________________________
O/~\ /~\O
These macroses allow to make more readable, more portable, and, in some
cases, more effective code. Now, instead (fattab.c):
______________O\_/_________________________________\_/O______________
#ifdef WITHFAT32
put_unsigned((unsigned)(clussec >> 16), 16, 4);
#endif
put_unsigned((unsigned)(clussec & 0xffffu), 16, 4);
_____________________________________________________________________
O/~\ /~\O
You may wrote:
______________O\_/_________________________________\_/O______________
#ifdef WITHFAT32
put_unsigned(hiword (clussec), 16, 4);
#endif
put_unsigned(loword (clussec), 16, 4);
_____________________________________________________________________
O/~\ /~\O
Or, instead:
______________O\_/_________________________________\_/O______________
#ifndef I86 /* the latter assumes byte ordering */
if (ClusterNum & 0x01)
idx =
((clusterbuff.bytes[0] & 0xf0) >> 4) | (clusterbuff.bytes[1] <<
4);
else
idx = clusterbuff.bytes[0] | ((clusterbuff.bytes[1] & 0x0f) << 8);
#else
if (ClusterNum & 0x01)
idx = (unsigned short)clusterbuff.word >> 4;
else
idx = clusterbuff.word & 0x0fff;
#endif
_____________________________________________________________________
O/~\ /~\O
You may wrote:
______________O\_/_________________________________\_/O______________
#ifndef I86 /* the latter assumes byte ordering */
idx = (lonibble (clusterbuff.bytes[1]) << 8) | clusterbuff.bytes[0];
>----------^^^^^^^^
#else
idx = clusterbuff.word;
#endif
if (lobyte (ClusterNum) & 0x01)
>-------^^^^^^
idx >>= 4;
idx &= 0x0fff;
_____________________________________________________________________
O/~\ /~\O
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
Freedos-kernel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freedos-kernel