Skip to content

Commit fae1f47

Browse files
committed
save a few bytes by using 32bit registers
1 parent fae1832 commit fae1f47

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

count.asm

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ program_header: ; Elf64_Phdr
5252
_start: ; argc is at `rsp`, argv is at `rsp + 8`
5353
mov rdi, [rsp + 16] ; put argv[1] into `rdi` (+ 8 to skip argv[0])
5454

55-
xor rcx, rcx ; zero
56-
xor rax, rax ; zero
55+
xor ecx, ecx ; zero
56+
xor eax, eax ; zero
5757
from_decimal_loop:
5858
movzx rdx, byte [rdi + rcx]
59-
sub rdx, '0'
59+
sub edx, '0'
6060

61-
mov rbx, rax
62-
shl rax, 3
63-
shl rbx, 1
64-
add rax, rbx
61+
mov ebx, eax
62+
shl eax, 3
63+
shl ebx, 1
64+
add eax, ebx
6565

66-
add rax, rdx
67-
inc rcx
66+
add eax, edx
67+
inc ecx
6868
cmp byte [rdi + rcx], 0
6969
jne from_decimal_loop
7070

0 commit comments

Comments
 (0)