assembly - Single Instruction Alternates of code snippets -


what'll single instruction alternates of following code snippets. have been trying hours , can't figure them out

  1. cmp ebx,eax jne x1 mov ebx,ecx jmp x2 x1: mov eax,ebx x2
  2. pushf mov bh,ffh cmp bl,0 jl x1 not bh x1: popf
  3. bt ax,15 jc x1 , eax,0000ffffh jmp x2 x1: or eax, ffff0000h x2:
    please provide explanation too.
    thanks

  1. looks cmpxchg ebx, ecx. if (eax == ebx) ebx = ecx else eax = ebx
  2. that gives 0ffh in bh if bl negative, or 00h otherwise. such that's sign extending, ie. movsx bx, bl
  3. that's same, it's sign extending ax testing sign bit directly, ie. movsx eax, ax. note doesn't affect flags opposed code snippet.

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -