1
0
mirror of https://gitlab.os-k.eu/os-k-team/kvisc.git synced 2023-08-25 14:05:46 +02:00
kvisc/vm/in/MEM

148 lines
2.5 KiB
Plaintext
Raw Normal View History

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
#
2019-08-03 17:41:44 +02:00
jmp 1
2019-07-17 20:26:03 +02:00
#
# RCX-dependent jump (LOOP) instruction
#
# IF (RCX > 0) THEN
# RCX = RCX - 1
# RIP = $1
# FI
#
2019-08-03 17:41:44 +02:00
loop 1
2019-07-17 20:26:03 +02:00
#
# Conditional absolute jumps (B)
#
2019-07-24 16:52:26 +02:00
# COMPARE(SignExtend($1), $2)
2019-07-17 20:26:03 +02:00
#
# 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
#
2019-08-03 17:41:44 +02:00
b 3
2019-07-17 20:26:03 +02:00
#---------------------------------------------------------------------------#
# Stack manipulation instructions #
#---------------------------------------------------------------------------#
#
# Unconditional jump with possible return (CALL)
#
# PUSH(RIP)
# JMP(RIP)
#
2019-08-03 17:41:44 +02:00
call 1
xcall2 2
xcall3 3
2019-07-17 20:26:03 +02:00
#
# Return to caller (RET)
#
# POP(RIP)
#
ret
#
# Make new stack frame (ENTER)
#
# PUSH(RBP)
# RBP = RSP
# RSP = RSP - $1
#
2019-08-03 17:41:44 +02:00
enter 1
2019-07-17 20:26:03 +02:00
#
# Leave stack frame (LEAVE)
#
# RSP = RBP
# POP(RBP)
#
leave
#
# PUSH value onto stack
#
# RSP = RSP - 8
# *RSP = $1
#
2019-08-03 17:41:44 +02:00
push 1
2019-07-17 20:26:03 +02:00
#
# POP value from stack
#
# $1 = *RSP
# RSP = RSP + 8
#
2019-08-03 17:41:44 +02:00
pop 1
2019-07-17 20:26:03 +02:00
2019-06-23 12:40:18 +02:00
#---------------------------------------------------------------------------#
# Movement instructions #
#---------------------------------------------------------------------------#
#
# Load Effective Address (LEA) instruction
#
# $1 = ADDR($2)
#
# For instance:
2019-07-18 22:49:31 +02:00
# LEA RAX, [RBX + RCX * 2 + 4]
2019-06-23 12:40:18 +02:00
# will result in:
2019-07-18 22:49:31 +02:00
# RAX = RBX + RCX * 2 + 4
2019-06-23 12:40:18 +02:00
#
# Preserves all flags
#
2019-08-03 17:41:44 +02:00
lea 2
2019-06-23 12:40:18 +02:00
#
2019-07-24 16:52:26 +02:00
# Move data (MOV) instruction
2019-06-23 12:40:18 +02:00
#
2019-07-24 16:52:26 +02:00
# $1 = SignExtend($2)
2019-06-23 12:40:18 +02:00
#
2019-08-03 17:41:44 +02:00
mov 2
2019-07-04 20:33:49 +02:00
#
2019-07-24 16:52:26 +02:00
# Load from memory with zero-extension (MOVSX/MOVZX) instruction
2019-07-04 20:33:49 +02:00
#
2019-07-24 16:52:26 +02:00
# $1 = ZeroExtend($2)
2019-07-04 20:33:49 +02:00
#
2019-08-03 17:41:44 +02:00
movzx 2
2019-06-23 12:40:18 +02:00
#
2019-07-24 16:52:26 +02:00
# Move with sign-extension (MOVSXx) instruction
2019-06-23 12:40:18 +02:00
#
2019-07-24 16:52:26 +02:00
# $1 = SignExtend($2 & (2^(8 * sizeof(x)) - 1)
2019-06-23 12:40:18 +02:00
#
2019-08-03 17:41:44 +02:00
movsxb 2
movsxw 2
movsxd 2
2019-06-23 12:40:18 +02:00
#
# Exchange (XCHG) instruction
#
# $_ = $1
# $1 = $2
# $2 = $_
#
2019-08-03 17:41:44 +02:00
xchg 2
2019-06-23 12:40:18 +02:00