2019-06-23 12:40:18 +02:00
|
|
|
# The OS/K Team licenses this file to you under the MIT license.
|
|
|
|
# See the LICENSE file in the project root for more information.
|
|
|
|
|
2019-07-17 20:26:03 +02:00
|
|
|
#---------------------------------------------------------------------------#
|
|
|
|
# Jump instructions #
|
|
|
|
#---------------------------------------------------------------------------#
|
|
|
|
|
|
|
|
#
|
|
|
|
# Jump (JMP) instruction
|
|
|
|
#
|
|
|
|
# RIP = $1
|
|
|
|
#
|
|
|
|
j ri
|
|
|
|
jmp ri
|
|
|
|
|
|
|
|
#
|
|
|
|
# RCX-dependent jump (LOOP) instruction
|
|
|
|
#
|
|
|
|
# IF (RCX > 0) THEN
|
|
|
|
# RCX = RCX - 1
|
|
|
|
# RIP = $1
|
|
|
|
# FI
|
|
|
|
#
|
|
|
|
loop ri
|
|
|
|
|
|
|
|
#
|
|
|
|
# Conditional absolute jumps (B)
|
|
|
|
#
|
|
|
|
# COMPARE($1, $2)
|
|
|
|
#
|
|
|
|
# IF (COND) THEN
|
|
|
|
# RIP = $3
|
|
|
|
# FI
|
|
|
|
#
|
|
|
|
# Sets CF, OF, ZF and SF according to the comparison's results
|
|
|
|
#
|
|
|
|
# This instruction is special in that the COND field specified is not evaluated
|
|
|
|
# before the instruction is executed, but after the comparison it effectuates
|
|
|
|
#
|
|
|
|
# Suffixing B with the REP suffix results in undefined behavior
|
|
|
|
#
|
|
|
|
b rm ri ri
|
|
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------#
|
|
|
|
# Stack manipulation instructions #
|
|
|
|
#---------------------------------------------------------------------------#
|
|
|
|
|
|
|
|
#
|
|
|
|
# Unconditional jump with possible return (CALL)
|
|
|
|
#
|
|
|
|
# PUSH(RIP)
|
|
|
|
# JMP(RIP)
|
|
|
|
#
|
|
|
|
call ri
|
|
|
|
|
|
|
|
#
|
|
|
|
# Return to caller (RET)
|
|
|
|
#
|
|
|
|
# POP(RIP)
|
|
|
|
#
|
|
|
|
ret
|
|
|
|
|
|
|
|
#
|
|
|
|
# Make new stack frame (ENTER)
|
|
|
|
#
|
|
|
|
# PUSH(RBP)
|
|
|
|
# RBP = RSP
|
|
|
|
# RSP = RSP - $1
|
|
|
|
#
|
|
|
|
enter i
|
|
|
|
|
|
|
|
#
|
|
|
|
# Leave stack frame (LEAVE)
|
|
|
|
#
|
|
|
|
# RSP = RBP
|
|
|
|
# POP(RBP)
|
|
|
|
#
|
|
|
|
leave
|
|
|
|
|
|
|
|
#
|
|
|
|
# PUSH value onto stack
|
|
|
|
#
|
|
|
|
# RSP = RSP - 8
|
|
|
|
# *RSP = $1
|
|
|
|
#
|
|
|
|
push rim
|
|
|
|
|
|
|
|
#
|
|
|
|
# POP value from stack
|
|
|
|
#
|
|
|
|
# $1 = *RSP
|
|
|
|
# RSP = RSP + 8
|
|
|
|
#
|
|
|
|
pop r
|
|
|
|
|
2019-06-23 12:40:18 +02:00
|
|
|
#---------------------------------------------------------------------------#
|
|
|
|
# Movement instructions #
|
|
|
|
#---------------------------------------------------------------------------#
|
|
|
|
|
|
|
|
#
|
|
|
|
# Load Effective Address (LEA) instruction
|
|
|
|
#
|
|
|
|
# $1 = ADDR($2)
|
|
|
|
#
|
|
|
|
# For instance:
|
|
|
|
# LEA RAX, [RBX + RCX + 4]
|
|
|
|
# will result in:
|
|
|
|
# RAX = RBX + RCX + 4
|
|
|
|
#
|
|
|
|
# Preserves all flags
|
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
lea r m
|
2019-06-23 12:40:18 +02:00
|
|
|
|
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
# Movement with sign-extension (MOV) instruction
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
|
|
|
# $1 = $2
|
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
mov r rim
|
|
|
|
mov m ri
|
|
|
|
|
|
|
|
#
|
|
|
|
# Movement with sign-extension (MOVSXx) instruction
|
|
|
|
#
|
|
|
|
# $1 = SignExtend($2 & (2^(8 * sizeof(x)) - 1)
|
|
|
|
#
|
|
|
|
movsxb r r
|
|
|
|
movsxw r r
|
|
|
|
movsxl r r
|
2019-06-23 12:40:18 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Movement with zero-extension (MOVZX) instruction
|
|
|
|
#
|
|
|
|
# $1 = ZeroExtend($2)
|
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
movzx r m
|
2019-06-23 12:40:18 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Exchange (XCHG) instruction
|
|
|
|
#
|
|
|
|
# $_ = $1
|
|
|
|
# $1 = $2
|
|
|
|
# $2 = $_
|
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
xchg r rm
|
2019-06-23 12:40:18 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Compare-and-exchange (CMPXCHG) instruction
|
|
|
|
#
|
|
|
|
# IF ($1 == RAX) THEN
|
|
|
|
# $1 = $2
|
|
|
|
# ZF = 1
|
|
|
|
# ELSE
|
|
|
|
# RAX = $1
|
|
|
|
# ZF = 0
|
|
|
|
# FI
|
|
|
|
#
|
|
|
|
# Preserves CF, OF and SF
|
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
cmpxchg rm r
|
|
|
|
|
|
|
|
#
|
|
|
|
# 3-operand rotation (ROTd)
|
|
|
|
#
|
2019-07-17 20:26:03 +02:00
|
|
|
# $3 -> $2 -> $1 -> $3 (ROTL)
|
|
|
|
# $1 -> $2 -> $3 -> $1 (ROTR)
|
2019-07-04 20:33:49 +02:00
|
|
|
#
|
|
|
|
rotr rm r r
|
|
|
|
rotl rm r r
|
2019-06-23 12:40:18 +02:00
|
|
|
|