X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Futil.h;h=b305d78697816a40303d98f012219d92750a2ddd;hp=76dd044eae32bfe11d9419d1a3cb25e42adf1530;hb=e8b26db00c934d141f16652cb8dcbeae23b17e48;hpb=8cee0ffb00cce3d81487f1161286ac299db7d044 diff --git a/src/util.h b/src/util.h index 76dd044..b305d78 100644 --- a/src/util.h +++ b/src/util.h @@ -5,12 +5,15 @@ #ifdef __GNUC__ #define INLINE __inline +#define PACKED __attribute__((packed)) #elif defined(__WATCOMC__) #define INLINE __inline +#define PACKED #else #define INLINE +#define PACKED #endif /* fast conversion of double -> 32bit int @@ -46,6 +49,14 @@ void perf_end(void); void debug_break(void); #pragma aux debug_break = "int 3"; + +void halt(void); +#pragma aux halt = "hlt"; + +void memset16(void *ptr, int val, int count); +#pragma aux memset16 = \ + "rep stosw" \ + parm[edi][eax][ecx]; #endif #ifdef __GNUC__ @@ -69,6 +80,13 @@ void debug_break(void); #define debug_break() \ asm volatile ("int $3") + +#define halt() \ + asm volatile("hlt") + +#define memset16(ptr, val, count) asm volatile ( \ + "rep stosw\n\t" \ + :: "D"(ptr), "a"(val), "c"(count)) #endif #ifdef _MSC_VER @@ -97,6 +115,16 @@ void debug_break(void); do { \ __asm { int 3 } \ } while(0) + +#define memset16(ptr, val, count) \ + do { \ + __asm { \ + mov edi, ptr \ + mov ecx, count \ + mov eax, val \ + rep stosw \ + } \ + } while(0) #endif #endif /* UTIL_H_ */