0

I was adding while loops to my compiler when I realized that I was getting an infinite loop when trying to compare doubles. I wrote this code to add 0.1 to b until it is not longer less than a, which should take a few loops but it is going forever.

global _start

section .rodata
                XMM_INC: dq 0.1

section .data
                a: dq 1.2
                b: dq 0.8
                msg: db "Looping!", 10, 0
                msg_len equ $-msg

section .text
_start:
                movsd xmm0, qword [b]
                ucomisd xmm0, qword [a]
                jg .while
                jmp .exit

.while:
                mov rax, 1
                mov rdi, 1
                mov rsi, msg
                mov rdx, msg_len
                syscall

                movsd xmm0, qword [b]
                addsd xmm0, qword [XMM_INC] 
                movsd qword [b], xmm0

                movsd xmm0, qword [b]
                ucomisd xmm0, qword [a]
                jg .while

.exit:
                mov rax, 60
                xor rdi, rdi
                syscall
joshjkk
  • 25
  • 1
  • 4
  • 1
    `ucomisd \ jg` is a strange combo, you probably [meant something else](https://stackoverflow.com/q/57188286/555045) – harold Jun 27 '23 at 08:49

0 Answers0