# ----------------------------------------------------------------------------- # A 64-bit function that returns the maximum value of its three 64-bit integer # arguments. The function has signature: # # int64_t maxofthree(int64_t x, int64_t y, int64_t z) # # Note that the parameters have already been passed in rdi, rsi, and rdx. # We just have to return the value in rax. # ----------------------------------------------------------------------------- .global maxofthree .text maxofthree: mov %rdi, %rax # result (rax) initially holds x # cmp sets condition codes based on 2nd operand minus first cmp %rsi, %rax # is x less than y? #Conditional move long cmovl %rsi, %rax # if so, set result to y cmp %rdx, %rax # is max(x,y) less than z? cmovl %rdx, %rax # if so, set result to z ret # the max will be in eax