From 8f18e3ad32684eee95e885e718655f93951128c3 Mon Sep 17 00:00:00 2001
From: Nomis101 <Nomis101@web.de>
Date: Wed, 15 Jul 2020 20:22:41 +0200
Subject: [PATCH] fix warnings when assembling with NASM 2.15

Adjust code to silence some new warnings added in NASM 2.15.
Fixes Issue #559.

Signed-off-by: Nomis101 <Nomis101@web.de>
---
 source/common/x86/const-a.asm |  2 +-
 source/common/x86/x86inc.asm  | 46 +++++++++++++++++++++++------------
 source/common/x86/x86util.asm |  4 ++-
 3 files changed, 34 insertions(+), 18 deletions(-)

diff --git a/source/common/x86/const-a.asm b/source/common/x86/const-a.asm
index acba18ccc..c8142bbb5 100644
--- a/source/common/x86/const-a.asm
+++ b/source/common/x86/const-a.asm
@@ -100,7 +100,7 @@ const pw_ff00,              times  8 dw 0xff00
 const pw_2000,              times 16 dw 0x2000
 const pw_8000,              times  8 dw 0x8000
 const pw_3fff,              times 16 dw 0x3fff
-const pw_32_0,              times  4 dw 32,
+const pw_32_0,              times  4 dw 32
                             times  4 dw 0
 const pw_pixel_max,         times 16 dw ((1 << BIT_DEPTH)-1)
 
diff --git a/source/common/x86/x86inc.asm b/source/common/x86/x86inc.asm
index 670699ec6..805aa1180 100644
--- a/source/common/x86/x86inc.asm
+++ b/source/common/x86/x86inc.asm
@@ -401,16 +401,6 @@ DECLARE_REG_TMP_SIZE 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14
     %endif
 %endmacro
 
-%macro DEFINE_ARGS_INTERNAL 3+
-    %ifnum %2
-        DEFINE_ARGS %3
-    %elif %1 == 4
-        DEFINE_ARGS %2
-    %elif %1 > 4
-        DEFINE_ARGS %2, %3
-    %endif
-%endmacro
-
 %if WIN64 ; Windows x64 ;=================================================
 
 DECLARE_REG 0,  rcx
@@ -429,7 +419,7 @@ DECLARE_REG 12, R15, 104
 DECLARE_REG 13, R12, 112
 DECLARE_REG 14, R13, 120
 
-%macro PROLOGUE 2-5+ 0 ; #args, #regs, #xmm_regs, [stack_size,] arg_names...
+%macro PROLOGUE 2-5+ 0, 0 ; #args, #regs, #xmm_regs, [stack_size,] arg_names...
     %assign num_args %1
     %assign regs_used %2
     ASSERT regs_used >= num_args
@@ -441,7 +431,15 @@ DECLARE_REG 14, R13, 120
         WIN64_SPILL_XMM %3
     %endif
     LOAD_IF_USED 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
-    DEFINE_ARGS_INTERNAL %0, %4, %5
+    %if %0 > 4
+         %ifnum %4
+             DEFINE_ARGS %5
+         %else
+             DEFINE_ARGS %4, %5
+         %endif
+     %elifnnum %4
+         DEFINE_ARGS %4
+     %endif
 %endmacro
 
 %macro WIN64_PUSH_XMM 0
@@ -537,7 +535,7 @@ DECLARE_REG 12, R15, 56
 DECLARE_REG 13, R12, 64
 DECLARE_REG 14, R13, 72
 
-%macro PROLOGUE 2-5+ 0; #args, #regs, #xmm_regs, [stack_size,] arg_names...
+%macro PROLOGUE 2-5+ 0, 0 ; #args, #regs, #xmm_regs, [stack_size,] arg_names...
     %assign num_args %1
     %assign regs_used %2
     %assign xmm_regs_used %3
@@ -547,7 +545,15 @@ DECLARE_REG 14, R13, 72
     PUSH_IF_USED 9, 10, 11, 12, 13, 14
     ALLOC_STACK %4
     LOAD_IF_USED 6, 7, 8, 9, 10, 11, 12, 13, 14
-    DEFINE_ARGS_INTERNAL %0, %4, %5
+    %if %0 > 4
+         %ifnum %4
+             DEFINE_ARGS %5
+         %else
+             DEFINE_ARGS %4, %5
+         %endif
+     %elifnnum %4
+         DEFINE_ARGS %4
+     %endif
 %endmacro
 
 %define has_epilogue regs_used > 9 || stack_size > 0 || vzeroupper_required
@@ -588,7 +594,7 @@ DECLARE_REG 6, ebp, 28
 
 DECLARE_ARG 7, 8, 9, 10, 11, 12, 13, 14
 
-%macro PROLOGUE 2-5+ ; #args, #regs, #xmm_regs, [stack_size,] arg_names...
+%macro PROLOGUE 2-5+ 0, 0 ; #args, #regs, #xmm_regs, [stack_size,] arg_names...
     %assign num_args %1
     %assign regs_used %2
     ASSERT regs_used >= num_args
@@ -603,7 +609,15 @@ DECLARE_ARG 7, 8, 9, 10, 11, 12, 13, 14
     PUSH_IF_USED 3, 4, 5, 6
     ALLOC_STACK %4
     LOAD_IF_USED 0, 1, 2, 3, 4, 5, 6
-    DEFINE_ARGS_INTERNAL %0, %4, %5
+    %if %0 > 4
+         %ifnum %4
+             DEFINE_ARGS %5
+         %else
+             DEFINE_ARGS %4, %5
+         %endif
+     %elifnnum %4
+         DEFINE_ARGS %4
+     %endif
 %endmacro
 
 %define has_epilogue regs_used > 3 || stack_size > 0 || vzeroupper_required
diff --git a/source/common/x86/x86util.asm b/source/common/x86/x86util.asm
index fa8712257..fe8939332 100644
--- a/source/common/x86/x86util.asm
+++ b/source/common/x86/x86util.asm
@@ -578,8 +578,10 @@
     %elif %1==2
         %if mmsize==8
             SBUTTERFLY dq, %3, %4, %5
-        %else
+        %elif %0==6
             TRANS q, ORDER, %3, %4, %5, %6
+        %else
+            TRANS q, ORDER, %3, %4, %5
         %endif
     %elif %1==4
         SBUTTERFLY qdq, %3, %4, %5
-- 
2.46.0

