Skip to content

Commit

Permalink
get rid of imul and re-use a 1
Browse files Browse the repository at this point in the history
  • Loading branch information
acheronfail committed Jan 22, 2024
1 parent fae19a0 commit fae1832
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions count.asm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ _start: ; argc is at `rsp`, argv is at `rsp + 8`
from_decimal_loop:
movzx rdx, byte [rdi + rcx]
sub rdx, '0'
imul rax, rax, 10

mov rbx, rax
shl rax, 3
shl rbx, 1
add rax, rbx

add rax, rdx
inc rcx
cmp byte [rdi + rcx], 0
Expand Down Expand Up @@ -85,7 +90,7 @@ to_decimal_loop:

write: ; args: `rax` syscall, `rdi` fd, `rsi` buf, `rdx` length
mov rax, 1
mov rdi, 1
mov rdi, rax
lea rdx, [output+11]
sub rdx, rsi
syscall
Expand Down

0 comments on commit fae1832

Please sign in to comment.