kvisc/vm/in/MEM

111 lines
1.7 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
#---------------------------------------------------------------------------#
# Stack manipulation instructions #
#---------------------------------------------------------------------------#
#
# Unconditional jump with possible return (CALL)
#
2019-09-08 19:04:07 +02:00
# PUSH(EIP)
# JMP(EIP)
2019-07-17 20:26:03 +02:00
#
2019-08-03 17:41:44 +02:00
call 1
2019-08-08 18:39:12 +02:00
call 2
call 3
2019-07-17 20:26:03 +02:00
#
# Return to caller (RET)
#
2019-09-08 19:04:07 +02:00
# POP(EIP)
2019-07-17 20:26:03 +02:00
#
2019-08-14 09:52:39 +02:00
ret 0
2019-08-16 13:29:38 +02:00
ret 1
2019-07-17 20:26:03 +02:00
#
# Make new stack frame (ENTER)
#
2019-09-08 19:04:07 +02:00
# PUSH(EBP)
# EBP = ESP
# ESP = ESP - $1
2019-07-17 20:26:03 +02:00
#
2019-08-14 09:52:39 +02:00
enter 0
2019-08-03 17:41:44 +02:00
enter 1
2019-08-14 09:52:39 +02:00
enter 2
2019-07-17 20:26:03 +02:00
#
# Leave stack frame (LEAVE)
#
2019-09-08 19:04:07 +02:00
# ESP = EBP
# POP(EBP)
2019-07-17 20:26:03 +02:00
#
2019-08-14 09:52:39 +02:00
leave 0
2019-07-17 20:26:03 +02:00
#
# PUSH value onto stack
#
2019-09-08 19:04:07 +02:00
# ESP = ESP - 8
# *ESP = $1
2019-07-17 20:26:03 +02:00
#
2019-08-03 17:41:44 +02:00
push 1
2019-08-08 18:39:12 +02:00
push 2
push 3
2019-07-17 20:26:03 +02:00
#
# POP value from stack
#
2019-09-08 19:04:07 +02:00
# $1 = *ESP
# ESP = ESP + 8
2019-07-17 20:26:03 +02:00
#
2019-08-14 20:23:05 +02:00
pop 0
2019-08-03 17:41:44 +02:00
pop 1
2019-08-08 18:39:12 +02:00
pop 2
2019-07-17 20:26:03 +02:00
2019-06-23 12:40:18 +02:00
#---------------------------------------------------------------------------#
# Movement instructions #
#---------------------------------------------------------------------------#
2019-08-14 20:23:05 +02:00
nul 1
nul 2
2019-06-23 12:40:18 +02:00
#
# Load Effective Address (LEA) instruction
#
# $1 = ADDR($2)
#
# For instance:
2019-09-08 19:04:07 +02:00
# LEA EAX, [EBX + ECX * 2 + 4]
2019-06-23 12:40:18 +02:00
# will result in:
2019-09-08 19:04:07 +02:00
# EAX = EBX + ECX * 2 + 4
2019-06-23 12:40:18 +02:00
#
2019-08-03 17:41:44 +02:00
lea 2
2019-06-23 12:40:18 +02:00
#
2019-08-14 20:23:05 +02:00
# Move data (MOV/MOVU) instructions
2019-06-23 12:40:18 +02:00
#
2019-08-14 20:23:05 +02:00
# $1 = SignExtend($2) (MOV)
# $1 = ZeroExtend($2) (MOVU)
2019-06-23 12:40:18 +02:00
#
2019-08-03 17:41:44 +02:00
mov 2
movzx 2
2019-06-23 12:40:18 +02:00
#
2019-08-14 20:23:05 +02:00
# Move with sign-extension (MOVx) 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-14 20:23:05 +02:00
movb 2
movw 2
movd 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