1

My code looks like this

ucomisd xmm14, xmm15 ; compare input in xmm14 and xmm15
ja first_num_greater ; jump ahead if xmm14 is larger
;first num smaller
movsd xmm0, xmm15 
movsd xmm9, xmm14
jmp printLarger


first_num_greater:
movsd xmm9, xmm15
movsd xmm0, xmm14


printLarger:
mov rdi, larger_num
mov rax, 1
call printf
movsd xmm0, xmm9

I'm trying to compare two floats. I'm able to print the larger number but then when I have a smaller number that I need to hold in the driver at xmm0, instead of holding a smaller number it's printing out 0.

Please enter two float numbers separated by white space. Press enter after the second input.
1.0 10.0
Your numbers are 1.0000000000000000 and 10.0000000000000000
The larger number is 10.0000000000000000
The driver module received this float number 0 and will keep it.
The driver module will return integer 0 to the operating system.

Did I miss something in moving registers? To simplify, howcome movsd xmm0, xmm9 isn't working as it should since the rest of the code above it works properly and prints the larger number. I'm trying to get the driver module to hold the smaller number.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
cheaseeds
  • 21
  • 2
  • 3
    None of the `xmm` registers is guaranteed to be preserved across function calls: https://stackoverflow.com/questions/18024672/what-registers-are-preserved-through-a-linux-x86-64-function-call – chtz Sep 06 '22 at 09:18

0 Answers0