X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Futil.h;h=b305d78697816a40303d98f012219d92750a2ddd;hp=ce43bbe125eb537bd56522c9f44588b36ee07f12;hb=e8b26db00c934d141f16652cb8dcbeae23b17e48;hpb=b0159ee29e4e616e4506d3cea5aee6ecc97aa93a diff --git a/src/util.h b/src/util.h index ce43bbe..b305d78 100644 --- a/src/util.h +++ b/src/util.h @@ -52,6 +52,11 @@ void debug_break(void); 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__ @@ -78,6 +83,10 @@ void halt(void); #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 @@ -106,6 +115,16 @@ void halt(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_ */