What is the easiest way to check an integer's remainder for modulus 2 in Nasm assembler?
问题 For example: int x = 35; if( x%2==1) { //do something } I just want to check the modulus value without assigning the result to x . Assume that value is in eax , so I can use DIV instruction, then put back the original value to eax etc.. but that seems inefficient. Can you suggest a better way? 回答1: To branch according to the modulo 2 of a value in al / ax / eax / rax : test al,1 jnz is_odd is_even: ; do something for even numbers. is_odd: ; do something for odd numbers. However, if all you