title: x86 Absolute Value Cofusion
body: <p>I am fairly new to x86 Intel assembly. Currently, I am trying to take the absolute value of a number passed in by a user. At the moment, the code simply spits out the number that is passed in back out. If it's -5, then the program states it's absolute value is still -5. If it's 5, the program states it's absolute value is 5. I am attempting to work with conditionals and ONLY jump to a section of code that would flip our sign bit when our number is less than zero. I do not think I am correctly jumping to this section of code, I do not know why. My code so far is as follows:</p>
  
  <pre><code>#compare with 0 and if less then flip sign
  
  #Syntax: int abs_val(int num)
  #Returns the absolute value of num
  abs_val:
  #num will be stored in %rdi
  push %rbp
  mov %rsp, %rbp
  cmpq $0, %rdi
  jl signFlip
  
  leave
  ret
  
  signFlip:
      neg %rdi
      mov %rdi, %rax
      leave
      ret
  </code></pre>
  
  <p>Please note: I am not looking for someone to type out the entire solution for me. I would prefer if I could be led in the right direction as in, "You need to use xyz function call instead of neg" or "You are not storing the value properly, try moving blah blah into this and that"</p>
  
  <p>Thank you in advance!</p>