fixed djgpp version of memset16, missing input clobbers
authorJohn Tsiombikas <nuclear@member.fsf.org>
Wed, 11 May 2022 03:17:13 +0000 (06:17 +0300)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Wed, 11 May 2022 03:17:13 +0000 (06:17 +0300)
src/util.h

index f93efc8..ec87a4d 100644 (file)
@@ -111,21 +111,26 @@ void halt(void);
 
 #ifdef __GNUC__
 #if defined(__i386__) || defined(__x86_64__)
-#define memset16(dest, val, count) asm volatile ( \
-       "cld\n\t" \
-       "test $1, %2\n\t" \
-       "jz 0f\n\t" \
-       "rep stosw\n\t" \
-       "jmp 1f\n\t" \
-       "0:\n\t" \
-       "shr $1, %2\n\t" \
-       "push %%ax\n\t" \
-       "shl $16, %%eax\n\t" \
-       "pop %%ax\n\t" \
-       "rep stosl\n\t" \
-       "1:\n\t"\
-       :: "D"(dest), "a"((uint16_t)(val)), "c"(count) \
-       : "memory")
+#define memset16(dest, val, count) \
+       do { \
+               uint32_t dummy1, dummy2; \
+               asm volatile ( \
+                       "cld\n\t" \
+                       "test $1, %%ecx\n\t" \
+                       "jz 0f\n\t" \
+                       "rep stosw\n\t" \
+                       "jmp 1f\n\t" \
+                       "0:\n\t" \
+                       "shr $1, %%ecx\n\t" \
+                       "push %%ax\n\t" \
+                       "shl $16, %%eax\n\t" \
+                       "pop %%ax\n\t" \
+                       "rep stosl\n\t" \
+                       "1:\n\t"\
+                       : "=D"(dummy1), "=c"(dummy2) \
+                       : "0"(dest), "a"((uint16_t)(val)), "1"(count) \
+                       : "flags", "memory"); \
+       } while(0)
 #else
 static void INLINE memset16(void *dest, uint16_t val, int count)
 {