#Triangle.asm

4 messages · Page 1 of 1 (latest)

tranquil sorrel
#
is_equilateral:
    movsd xmm0, [rdi]      ; a
    movsd xmm1, [rdi+8]    ; b
    movsd xmm2, [rdi+16]   ; c

    ucomisd xmm0, xmm1
    sete  bl           ; bl = 1 if a == b

    ucomisd xmm1, xmm2
    sete  dl           ; dl = 1 if b == c

    and bl, dl         ; bl && dl

    movzx rax, bl    ; move result to rax
    
    ret                ; return it 

I am solving triangle in assembly, I don't understand why the equilateral function isn't working and I highly appreciate any help. Tests 1 and 5 are failing, but I presume it is returning false for everything.

undone ruin
#

Because of the way the input is passed into the function (a C struct by value--not reference), it is helpful to check with a debugger what values actually start at RDI.

#

Since it is by value they are stored on the stack instead of the registers.

tranquil sorrel
#

Oh! I didn't know that! Thank you!