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
julianb0 fa7e365b98
up
2019-08-08 18:39:12 +02:00

153 lines
2.6 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.
#---------------------------------------------------------------------------#
# Jump instructions #
#---------------------------------------------------------------------------#
#
# Jump (JMP) instruction
#
# RIP = $1
#
jmp 1
#
# RCX-dependent jump (LOOP) instruction
#
# IF (RCX > 0) THEN
# RCX = RCX - 1
# RIP = $1
# FI
#
loop 1
#
# Conditional absolute jumps (branches) (BCH)
#
# COMPARE(SignExtend($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
#
bch 3
#---------------------------------------------------------------------------#
# 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
#
# Make new stack frame (ENTER)
#
# PUSH(RBP)
# RBP = RSP
# RSP = RSP - $1
#
enter
enter 1
#
# Leave stack frame (LEAVE)
#
# RSP = RBP
# POP(RBP)
#
leave
#
# 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 1
pop 2
pop 3
#---------------------------------------------------------------------------#
# Movement instructions #
#---------------------------------------------------------------------------#
#
# Load Effective Address (LEA) instruction
#
# $1 = ADDR($2)
#
# For instance:
# LEA RAX, [RBX + RCX * 2 + 4]
# will result in:
# RAX = RBX + RCX * 2 + 4
#
# Preserves all flags
#
lea 2
#
# Move data (MOV) instruction
#
# $1 = SignExtend($2)
#
mov 2
#
# Load from memory with zero-extension (MOVSX/MOVZX) instruction
#
# $1 = ZeroExtend($2)
#
movzx 2
#
# Move with sign-extension (MOVSXx) instruction
#
# $1 = SignExtend($2 & (2^(8 * sizeof(x)) - 1)
#
movsxb 2
movsxw 2
movsxd 2
#
# Exchange (XCHG) instruction
#
# $_ = $1
# $1 = $2
# $2 = $_
#
xchg 2