From e5413255949140efda5ab0b1e27ec2363fcee542 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Wed, 11 May 2022 06:17:13 +0300 Subject: [PATCH] fixed djgpp version of memset16, missing input clobbers --- src/util.h | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/util.h b/src/util.h index f93efc8..ec87a4d 100644 --- a/src/util.h +++ b/src/util.h @@ -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) { -- 1.7.10.4