diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2011-07-09 15:31:13 +0400 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2011-07-09 15:31:13 +0400 |
commit | d0e5ff230580ce1d023f9211302b857bb4e986d8 (patch) | |
tree | 9b3805bf6feae9693bbab4f502dc89e7786f8956 | |
parent | 4bcb49a4d90fcd0ae4ca67fcdddb1de33c76039e (diff) | |
download | gcd-d0e5ff230580ce1d023f9211302b857bb4e986d8.tar.gz |
No need of stack, we have extra registers: %r8 - %r15
-rw-r--r-- | assembler/gcd-x86_64-linux.s | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/assembler/gcd-x86_64-linux.s b/assembler/gcd-x86_64-linux.s index 5a76aac..9ea9460 100644 --- a/assembler/gcd-x86_64-linux.s +++ b/assembler/gcd-x86_64-linux.s @@ -109,14 +109,13 @@ _start: xor %rax, %rax gcd_loop: pop %rsi # get next command line argument - # Well, we used all rrgisters, now we DO NEED stack :-) - push %rcx # save argument counter - push %rax # save current GCD + mov %rcx, %r8 # save argument counter + mov %rax, %r9 # save current GCD call str2uint # convert string at rsi to integer at rbx - pop %rax # restore current GCD + mov %r9, %rax # restore current GCD call gcd2 # gcd of rax and rbx (returned by str2uint) # now rax is a GCD - pop %rcx # restore argument counter + mov %r8, %rcx # restore argument counter loop gcd_loop call print # print rax with GCD |