andl with a parameter? x86 assembly -



andl with a parameter? x86 assembly -

pushl %ebp movl %esp, %ebp subl $36, %esp //allocate 36 btyes local vars movl 8(%ebp), %eax // eax = n andl $1, %eax //how can u andl parameter? parameter can greater 1 testl %eax, %eax jmp .l4 cmpl $2, 8(%ebp) jne .l6 .l4: movl 8(%ebp), %eax //eax = n movl %eax, -28(%ebp) //x = eax movl $1431655766, -32(%ebp) //y = 1431655766 movl -32(%ebp), %eax //eax = y imull -28(%ebp) //edx = x * eax movl %edx, %ecx //ecx = edx movl -28(%ebp), %eax //eax = x sarl $31, %eax //eax = eax >> 31 movl %ecx, %edx //edx = ecx subl %eax, %edx //edx = edx - eax movl %edx, -24(%ebp) //z = edx movl -24(%ebp), %eax //eax = z addl %eax, %eax //eax = eax+eax addl -24(%ebp), %eax //eax = z+eax movl -28(%ebp), %ecx //ecx = x subl %eax, %ecx //ecx = ecx-eax movl %ecx, -24(%ebp) //z = ecx cmpl $0, -24(%ebp) //compare z , 0 jne .l7 //if not equal jmp .l7 cmpl $3, 8(%ebp) //compare n , 3 jne .l6 //if not equal jmp .l6

okay have assembly snippet, , i'm wondering how can andl $1 , parameter, parameter can greater 1. testl seems useless, because jmp jumps regardless. thoughts? thanks.

edit: i've updated code, not sure if right reasoning of it. confused imull -28(%ebp)

$1 short form of constant (number) without leading zeros. in 32-bit-environment (%eax!) equivalent 0x00000001 , means: set bits except rightmost zero, allow rightmost bit untouched. here used isolate boolean value (0=false or 1=true) or determine oddness (0=even, 1=odd).

assembly x86

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -