X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Futil.h;h=b305d78697816a40303d98f012219d92750a2ddd;hp=6d200b7824f14dbcff470db501150d193d6b7920;hb=e8b26db00c934d141f16652cb8dcbeae23b17e48;hpb=8c475e1fd504f46cbb8a882e760714925c012890 diff --git a/src/util.h b/src/util.h index 6d200b7..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 @@ -43,6 +46,17 @@ void perf_end(void); "sub eax, [perf_start_count]" \ "mov [perf_interval_count], eax" \ modify [eax ebx ecx edx]; + +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__ @@ -63,6 +77,16 @@ void perf_end(void); : "=m"(perf_interval_count) \ : "m"(perf_start_count) \ : "%eax", "%ebx", "%ecx", "%edx") + +#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 @@ -86,6 +110,21 @@ void perf_end(void); mov [perf_interval_count], eax \ } \ } while(0) + +#define debug_break() \ + 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_ */