Reputation: 159
What'll be the single Instruction alternates of following code snippets. I have been trying for hours and can't really figure them out
CMP EBX,EAX
JNE X1
MOV EBX,ECX
JMP X2
X1: MOV EAX,EBX
X2
PUSHF
MOV BH,FFH
CMP BL,0
JL X1
NOT BH
X1: POPF
BT AX,15
JC X1
AND EAX,0000FFFFH
JMP X2
X1: OR EAX, FFFF0000H
X2:
Upvotes: 0
Views: 77
Reputation: 58792
cmpxchg ebx, ecx
. if (eax == ebx) ebx = ecx else eax = ebx
0FFh
in bh
if bl
is negative, or 00h
otherwise. As such that's just sign extending, ie. movsx bx, bl
ax
by testing the sign bit directly, ie. it is movsx eax, ax
. But note this doesn't affect flags as opposed to the code snippet.Upvotes: 3