Exception thrown at 0x00007FF69997AA5C in HW04_Q01.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF. occurred

-2

I wrote a procedure in a x64 assembly (masm) and when the execution of the code reaches the ret statment it gives this error : Exception thrown at 0x00007FF69997AA5C in HW04_Q01.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF. occurred

getSquareRoot proc
.data?
    temp2 complex <>
    a real8 ?
    b real8 ?
    x real8 ?
.data
    zero real8 0.0
    _two real8 2.0
    minusOne real8 -1.0
.code
    movsd xmm0, real8 ptr [rsi]
    movsd xmm1, real8 ptr [rsi + 8]
    movsd a, xmm0
    movsd b, xmm1
    mulsd xmm0, a
    mulsd xmm1, b
    movsd xmm2, xmm0
    addsd xmm2, xmm1
    movsd x, xmm2
    movsd xmm1, b
    _IF:
        ucomisd xmm1, zero
        jb _else 
            movsd xmm0,x
            call sqrt
            addsd xmm0, a
            divsd xmm0, _two
            call sqrt
            movsd temp2.real, xmm0

            movsd xmm0,x
            call sqrt
            movsd xmm1, minusOne
            mulsd xmm1, a
            addsd xmm0, xmm1
            divsd xmm0, _two
            call sqrt
            movsd temp2.imag, xmm0
        jmp _endIf
    _else:
            movsd xmm0,x
            call sqrt
            addsd xmm0, a
            divsd xmm0, _two
            call sqrt
            movsd temp2.real, xmm0

            movsd xmm0,x
            call sqrt
            movsd xmm1, minusOne
            mulsd xmm1, a
            addsd xmm0, xmm1
            divsd xmm0, _two
            call sqrt
            mulsd xmm0, minusOne
            movsd temp2.imag, xmm0
    _endIf:
    movsd xmm0, temp2.real
    movsd xmm1, temp2.imag
ret
getSquareRoot endp
assembly
x86-64
masm
asked on Stack Overflow Nov 6, 2019 by ahmed alzahrani • edited Nov 6, 2019 by Amy

1 Answer

0

actually i replaced each call to sqrt() C function with the mnemonic sqrtsd since the values i'm dealing with all stored in SSE registers(xmm0, xmm1, xmm2, ...) and it worked

answered on Stack Overflow Nov 6, 2019 by ahmed alzahrani

User contributions licensed under CC BY-SA 3.0