diff --git a/ChangeLog b/ChangeLog
index 191c94df7eb2c52d5d1510d4ce339f98865f5b33..d0f7cd361777423d5afd243a315e6fc2686706f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
 	From Martin Storsj�:
 	* x86_64/machine.m4 (W64_ENTRY, W64_EXIT): New macros for
 	supporting W64 ABI.
+	* x86_64: Updated all assembly files to use them.
 
 	* configure.ac (W64_ABI): New variable, set when compiling for
 	W64 ABI (64-bit M$ windows).
diff --git a/x86_64/aes-decrypt-internal.asm b/x86_64/aes-decrypt-internal.asm
index 8f0df73714d594a723ec97909c6e9b452521cedd..2c94d0f6815d55915012bea975d3bef881398d70 100644
--- a/x86_64/aes-decrypt-internal.asm
+++ b/x86_64/aes-decrypt-internal.asm
@@ -55,6 +55,7 @@ define(<TMP>,<%rbp>)
 	.text
 	ALIGN(4)
 PROLOGUE(_nettle_aes_decrypt)
+	W64_ENTRY(5, 0)
 	test	PARAM_LENGTH, PARAM_LENGTH
 	jz	.Lend
 
@@ -129,5 +130,6 @@ PROLOGUE(_nettle_aes_decrypt)
 	pop	%rbp
 	pop	%rbx
 .Lend:
+	W64_EXIT(5, 0)
 	ret
 EPILOGUE(_nettle_aes_decrypt)
diff --git a/x86_64/aes-encrypt-internal.asm b/x86_64/aes-encrypt-internal.asm
index c23feb6218db8591a4a803734fcaafda0a654e3e..dd516c8ccbacd6a71be1e3b02592178ec4059bf0 100644
--- a/x86_64/aes-encrypt-internal.asm
+++ b/x86_64/aes-encrypt-internal.asm
@@ -55,6 +55,7 @@ define(<TMP>,<%rbp>)
 	.text
 	ALIGN(4)
 PROLOGUE(_nettle_aes_encrypt)
+	W64_ENTRY(5, 0)
 	test	PARAM_LENGTH, PARAM_LENGTH
 	jz	.Lend
 
@@ -129,5 +130,6 @@ PROLOGUE(_nettle_aes_encrypt)
 	pop	%rbp
 	pop	%rbx
 .Lend:
+	W64_EXIT(5, 0)
 	ret
 EPILOGUE(_nettle_aes_encrypt)
diff --git a/x86_64/camellia-crypt-internal.asm b/x86_64/camellia-crypt-internal.asm
index e940342ba33ec9b7562e00e8d1e4afcf33765f3c..b7bd93f375369515815594ed86873c4e24a3dba5 100644
--- a/x86_64/camellia-crypt-internal.asm
+++ b/x86_64/camellia-crypt-internal.asm
@@ -125,6 +125,7 @@ C	xorl	XREG(TMP), XREG($1)
 	ALIGN(4)
 PROLOGUE(_nettle_camellia_crypt)
 
+	W64_ENTRY(5, 0)
 	test	LENGTH, LENGTH
 	jz	.Lend
 
@@ -182,5 +183,6 @@ PROLOGUE(_nettle_camellia_crypt)
 	pop	%rbp
 	pop	%rbx
 .Lend:
+	W64_EXIT(5, 0)
 	ret
 EPILOGUE(_nettle_camellia_crypt)
diff --git a/x86_64/memxor.asm b/x86_64/memxor.asm
index 7a5a23b688708103d730dba3c5cd78e4bcd5b6ca..117ae70eb5f3d92f4d5983307aecc03beae85529 100644
--- a/x86_64/memxor.asm
+++ b/x86_64/memxor.asm
@@ -40,6 +40,7 @@ define(<USE_SSE2>, <no>)
 	ALIGN(4)
 
 PROLOGUE(memxor)
+	W64_ENTRY(3, 0)
 	mov	%rdx, %r10
 	mov	%rdi, %rdx
 	jmp 	.Lmemxor3_entry
@@ -50,6 +51,7 @@ EPILOGUE(memxor)
 	ALIGN(4)
 	
 PROLOGUE(memxor3)
+	W64_ENTRY(4, 0)
 	C %cl needed for shift count, so move away N
 	mov	%rcx, N
 .Lmemxor3_entry:
@@ -200,6 +202,8 @@ C 	jz	.Ldone
 	xor	(BP, N), TMP
 	mov	TMP, (DST, N)
 
+	C ENTRY might have been 3 args, too, but it doesn't matter for the exit
+	W64_EXIT(4, 0)
 	ret
 
 .Lfinal:
@@ -214,6 +218,8 @@ C 	jz	.Ldone
 	jnc	.Lfinal_loop
 
 .Ldone:
+	C ENTRY might have been 3 args, too, but it doesn't matter for the exit
+	W64_EXIT(4, 0)
 	ret
 
 ifelse(USE_SSE2, yes, <
@@ -247,6 +253,8 @@ ifelse(USE_SSE2, yes, <
 	movdqu	(BP), %xmm1
 	pxor	%xmm0, %xmm1
 	movdqa	%xmm1, (DST)
+	C ENTRY might have been 3 args, too, but it doesn't matter for the exit
+	W64_EXIT(4, 0)
 	ret
 >)	
 	
diff --git a/x86_64/serpent-decrypt.asm b/x86_64/serpent-decrypt.asm
index b2bca664cb00a26ab7d7a1a1b42429675b0bd729..5055d71569aefed59099a19df094cc22d50358ba 100644
--- a/x86_64/serpent-decrypt.asm
+++ b/x86_64/serpent-decrypt.asm
@@ -525,6 +525,7 @@ define(<WLTI>, <
 	ALIGN(4)
 PROLOGUE(nettle_serpent_decrypt)
         C save all registers that need to be saved
+	W64_ENTRY(4, 13)
 	push	%rbx
 	push	%rbp
 	push	%r12
@@ -697,4 +698,5 @@ PROLOGUE(nettle_serpent_decrypt)
 	pop	%r12
 	pop	%rbp
 	pop	%rbx
+	W64_EXIT(4, 13)
 	ret
diff --git a/x86_64/serpent-encrypt.asm b/x86_64/serpent-encrypt.asm
index fe60f7c16b59c43faaf939a48ffb30e9333df714..5751b30ed321f772234291c23546f0764af4a44e 100644
--- a/x86_64/serpent-encrypt.asm
+++ b/x86_64/serpent-encrypt.asm
@@ -552,6 +552,7 @@ define(<WLT>, <
 	ALIGN(4)
 PROLOGUE(nettle_serpent_encrypt)
         C save all registers that need to be saved
+	W64_ENTRY(4, 13)
 	push	%rbx
 	push	%rbp
 	push	%r12
@@ -732,4 +733,5 @@ C parallell.
 	pop	%r12
 	pop	%rbp
 	pop	%rbx
+	W64_EXIT(4, 13)
 	ret
diff --git a/x86_64/sha1-compress.asm b/x86_64/sha1-compress.asm
index a912ce0a54dee9b2812474b36aaf96cf61327445..1abbb69811f72cb6104089bf259c8fc773212158 100644
--- a/x86_64/sha1-compress.asm
+++ b/x86_64/sha1-compress.asm
@@ -126,6 +126,7 @@ C adding, and then rotating back.
 	ALIGN(4)
 PROLOGUE(_nettle_sha1_compress)
 	C save all registers that need to be saved
+	W64_ENTRY(2, 0)
 	
 	sub	$68, %rsp	C  %rsp = W
 
@@ -250,5 +251,6 @@ PROLOGUE(_nettle_sha1_compress)
 	addl	SE, 16(STATE)
 
 	add	$68, %rsp
+	W64_EXIT(2, 0)
 	ret
 EPILOGUE(_nettle_sha1_compress)