Skip to content

Commit 760e633

Browse files
committed
Use the return value of memset to avoid using an additional register
1 parent b48fd2c commit 760e633

File tree

1 file changed

+5
-8
lines changed
  • contents/huffman_encoding/code/asm-x64

1 file changed

+5
-8
lines changed

contents/huffman_encoding/code/asm-x64/huffman.s

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,23 +226,20 @@ decode_done:
226226
# rsi - Huffman-tree root (ptr)
227227
generate_codebook:
228228
push r12
229-
push r13
230-
sub rsp, bitstr_size + 8 # 8 extra bytes for alignment
231-
mov r12, rdi
232-
mov r13, rsi
229+
sub rsp, bitstr_size + 16 # 16 extra bytes for alignment
230+
mov r12, rsi
233231
xorps xmm0, xmm0 # Create a 0-initialized bitstring. This will be
234232
movaps XMMWORD PTR [rsp], xmm0 # used in the recursive function calls
235233
movaps XMMWORD PTR [rsp + 16], xmm0
236234
mov QWORD PTR [rsp + 32], 0
237235
xor rsi, rsi
238236
mov rdx, codebook_size
239237
call memset
240-
mov rdi, r12
241-
mov rsi, r13
238+
mov rdi, rax
239+
mov rsi, r12
242240
mov rdx, rsp
243241
call generate_codebook_recurse
244-
add rsp, bitstr_size + 8
245-
pop r13
242+
add rsp, bitstr_size + 16
246243
pop r12
247244
ret
248245

0 commit comments

Comments
 (0)