0

I should compare my value in rdx with 0 in this code. What is the most suitable variant : use cmp,0 or use test cmp, cmp Thanks !

    xor rax, rax
    cmp byte[rdi],'-'
    jne parse_uint  
    inc rdi
    call parse_uint 
    cmp rdx, 0
    je .not_number 
    neg rax 
    inc rdx
    ret

.not_number
    xor rax, rax
    ret
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847

1 Answers1

-2

cmp is a mathematical operation (make a subtraction, throw a result and use only flags)

test is a logical operation (check if the requireds bit are set)

in this situation you should compare to values so you need cmp