From d0e5ff230580ce1d023f9211302b857bb4e986d8 Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Sat, 9 Jul 2011 15:31:13 +0400 Subject: No need of stack, we have extra registers: %r8 - %r15 --- assembler/gcd-x86_64-linux.s | 9 ++++----- 1 file 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 -- cgit v1.2.3