x64_cheatsheet.pdf
0.18MB

https://modoocode.com/en/inst/aaa

S = Source

D = Destination

1. 데이터 이동

1-1. 접미사 한 개

The Intel-syntax extension instructions

  • ‘movsx’ — sign-extend ‘reg8/mem8’ to ‘reg16’.
  • ‘movsx’ — sign-extend ‘reg8/mem8’ to ‘reg32’.
  • ‘movsx’ — sign-extend ‘reg8/mem8’ to ‘reg64’ (x86-64 only).
  • ‘movsx’ — sign-extend ‘reg16/mem16’ to ‘reg32’
  • ‘movsx’ — sign-extend ‘reg16/mem16’ to ‘reg64’ (x86-64 only).
  • ‘movsxd’ — sign-extend ‘reg32/mem32’ to ‘reg64’ (x86-64 only).
  • ‘movzx’ — zero-extend ‘reg8/mem8’ to ‘reg16’.
  • ‘movzx’ — zero-extend ‘reg8/mem8’ to ‘reg32’.
  • ‘movzx’ — zero-extend ‘reg8/mem8’ to ‘reg64’ (x86-64 only).
  • ‘movzx’ — zero-extend ‘reg16/mem16’ to ‘reg32’
  • ‘movzx’ — zero-extend ‘reg16/mem16’ to ‘reg64’ (x86-64 only).

are called ‘movsbw/movsxb/movsx’, ‘movsbl/movsxb/movsx’, ‘movsbq/movsb/movsx’, ‘movswl/movsxw’, ‘movswq/movsxw’, ‘movslq/movsxl’, ‘movzbw/movzxb/movzx’, ‘movzbl/movzxb/movzx’, ‘movzbq/movzxb/movzx’, ‘movzwl/movzxw’ and ‘movzwq/movzxw’ in AT&T syntax.

mov S, D ( S의 데이터를 D에 복사합니다. )

push S ( S를 스택의 맨 위에 복사하고 RSP/ESP를 4칸 올립니다. (SP 주소 값에 4 빼기) )

pop D ( 스택의 맨 위 데이터를 D에 복사하고 RSP/ESP를 4칸 내립니다. (SP 주소 값에 4 더하기) )

1-2. 접미사 없음

The Intel-syntax conversion instructions

  • ‘cbw’ — sign-extend byte in ‘%al’ to word in ‘%ax’,
  • ‘cwde’ — sign-extend word in ‘%ax’ to long in ‘%eax’,
  • ‘cwd’ — sign-extend word in ‘%ax’ to long in ‘%dx:%ax’,
  • ‘cdq’ — sign-extend dword in ‘%eax’ to quad in ‘%edx:%eax’,
  • ‘cdqe’ — sign-extend dword in ‘%eax’ to quad in ‘%rax’ (x86-64 only),
  • ‘cqo’ — sign-extend quad in ‘%rax’ to octuple in ‘%rdx:%rax’ (x86-64 only),

are called ‘cbtw’, ‘cwtl’, ‘cwtd’, ‘cltd’, ‘cltq’, and ‘cqto’ in AT&T naming. as accepts either naming for these instructions.

cbw(Convert Byte to Word) ( AL을 부호 확장을 해서 AX로 만듭니다. )

cwde(Convert Word to Dword) ( AX를 부호 확장을 해서 EAX로 만듭니다. )

cwd(Convert Word to Dword) ( AX를 부호 확장을 해서 DX와 AX에 저장합니다. )

cdq(Convert Dword to Quad) ( EAX를 부호 확장을 해서 EDX와 EAX에 저장합니다. )

cdqe(Convert Dword to Quad) (EAX를 부호 확장을 해서 RAX에 저장합니다. )(x64 전용)

cqo(Convert Quad to Octuple) (RAX를 부호 확장을 해서 RDX와 RAX에 저장합니다. )(x64 전용)

2. 산술 연산

2-1. 단항 연산

inc D ( D에 1을 더합니다. )

dec D ( D에 1을 뺍니다. )

neg D ( 2의 보수 )

not D ( not 비트 연산 )

2-2. 비트 연산

lea S, D ( D의 주소를 계산하여 S에 저장합니다. )

add S, D ( S와 D를 더한 값을 S에 저장합니다. 피연산자에 메모리 주소를 넣을 순 있지만 두 개 모두 메모리 주소를 넣을 순 없습니다. )

sub S, D ( S에서 D를 뺀 값을 S에 저장합니다.)

imul S, D ( 부호 있는 곱하기, S와 D를 곱해서 S에 저장합니다. )

mul S, D ( 부호 없는 곱하기, S와 D를 곱해서 S에 저장합니다. )

xor S, D ( S와 D를 xor 하고 결과를 S에 저장합니다. )

or S, D ( S와 D를 or 연산하고 결과를 S에 저장합니다. )

and S, D ( S와 D를 and 연산하고 결과를 S에 저장합니다. )

3. 분기

cmp S, D ( S와 D를 비교하여 ZF랑 CF에 저장한다. )

3-1. 무조건분기

jmp L ( L 위치로 무조건 이동 )

3-2. 조건분기

명령어 의미 부등호 플래그 조건
ja jump if avobe > CF = 0 and ZF = 0
jae jump if avobe or equal >= CF = 0 or ZF = 1
jb jump if below < CF = 1
jbe jump if below or equal <= CF = 1 or ZF = 1
jc jump if carry flag set   CF = 1
jcxz jump if CX is 0   CX = 0
je jump if equal == ZF = 1
jecxz jump if ECX is 0   ECX = 0
jg jump if grater(signed) > ZF = 0, and SF = OF
jz jump if zero == ZF = 1

4. 호출

call L ( L 함수 호출 )

728x90

+ Recent posts