kvisc/vm/in/MEM

111 lines
1.7 KiB
Plaintext

# The OS/K Team licenses this file to you under the MIT license.
# See the LICENSE file in the project root for more information.
#---------------------------------------------------------------------------#
# Stack manipulation instructions #
#---------------------------------------------------------------------------#
#
# Unconditional jump with possible return (CALL)
#
# PUSH(RIP)
# JMP(RIP)
#
call 1
call 2
call 3
#
# Return to caller (RET)
#
# POP(RIP)
#
ret 0
ret 1
#
# Make new stack frame (ENTER)
#
# PUSH(RBP)
# RBP = RSP
# RSP = RSP - $1
#
enter 0
enter 1
enter 2
#
# Leave stack frame (LEAVE)
#
# RSP = RBP
# POP(RBP)
#
leave 0
#
# PUSH value onto stack
#
# RSP = RSP - 8
# *RSP = $1
#
push 1
push 2
push 3
#
# POP value from stack
#
# $1 = *RSP
# RSP = RSP + 8
#
pop 0
pop 1
pop 2
#---------------------------------------------------------------------------#
# Movement instructions #
#---------------------------------------------------------------------------#
nul 1
nul 2
#
# Load Effective Address (LEA) instruction
#
# $1 = ADDR($2)
#
# For instance:
# LEA RAX, [RBX + RCX * 2 + 4]
# will result in:
# RAX = RBX + RCX * 2 + 4
#
lea 2
#
# Move data (MOV/MOVU) instructions
#
# $1 = SignExtend($2) (MOV)
# $1 = ZeroExtend($2) (MOVU)
#
mov 2
movzx 2
#
# Move with sign-extension (MOVx) instruction
#
# $1 = SignExtend($2 & (2^(8 * sizeof(x)) - 1)
#
movb 2
movw 2
movd 2
#
# Exchange (XCHG) instruction
#
# $_ = $1
# $1 = $2
# $2 = $_
#
xchg 2