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/ALU
2019-07-24 16:52:26 +02:00

166 lines
3.1 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.
#---------------------------------------------------------------------------#
# Logical instructions #
#---------------------------------------------------------------------------#
#
# Bitwise OR operation
#
# $dest = $src1 OR $src2
#
# Preserves all flags
#
or r r ri
#
# Bitwise AND operation
#
# $dest = $src1 AND $src2
#
# Preserves all flags
#
and r r ri
#
# Bitwise XOR operation
#
# $dest = $src1 XOR $src2
#
# Preserves all flags
#
xor r r ri
#
# Logical left/right shift (SHL/SHR)
#
# $dest = $src1 << $src2 (SHL)
# $dest = $src1 >> $src2 (SHR)
#
# Preserves all flags
#
shl r r ri
shr r r ri
#
# Arithmetical left/right shift (SAL/SAR)
#
# $dest = $src1 <<< $src2 (SAL)
# $dest = $src1 >>> $src2 (SAR)
#
# Preserves all flags
#
sal r r ri
sar r r ri
#---------------------------------------------------------------------------#
# Arithmetic instructions #
#---------------------------------------------------------------------------#
#
# CMP Comparison instruction
#
# SignExtend($1) - $2
#
# Sets CF if unsigned integer overflow occur, clears it otherwise
# Sets OF is signed integer overflow occur, clears it otherwise
# Sets ZF and SF according to the result
#
cmp r ri
cmp m ri
#
# Arithmetical ADD operation
#
# $dest1 = $src1 + $src2
#
# Sets CF if unsigned integer overflow occur, clears it otherwise
# Sets OF is signed integer overflow occur, clears it otherwise
# Sets ZF and SF according to the result
#
add r r ri
addf r r ri
#
# Arithmetical SUB operation
#
# $dest = $src1 - $src2
#
# Sets CF if unsigned integer overflow occur, clears it otherwise
# Sets OF is signed integer overflow occur, clears it otherwise
# Sets ZF and SF according to the result
#
sub r r ri
subf r r ri
#
# Arithmetical ADD/SUB operation, with carry/overflow
#
# $dest = $src1 + $src2 + CF (ADC)
# $dest = $src1 - $src2 - CF (SBB)
#
# Sets CF if unsigned integer overflow occur, clears it otherwise
# Sets OF is signed integer overflow occur, clears it otherwise
# Sets ZF and SF according to the result
#
adcx r r ri
sbbx r r ri
#
# Arithmetical MUL operation
#
# $dest = LO($src1 * $src2)
#
# Preserves ZF and SF
# Sets CF and OF if HI($src1 * $src2) > 0, clears them otherwise
#
mul r r ri
mulf r r ri
# Arithmetical unsigned MUL operation
#
# $dest1 = HI($dest2 * $src)
# $dest2 = LO($dest2 * $src)
#
# Preserves all flags
#
mulhi r r ri
# Arithmetical signed MUL operation
#
# $dest1 = HI($dest2 ** $src)
# $dest2 = LO($dest2 ** $src)
#
# Preserves all flags
#
imulhi r r ri
#
# Arithmetical unsigned DIV operation
#
# $dest = $src1 DIV $src2
#
# Preserves all flags
#
div r r ri
#
# Arithmetical signed DIV operation
#
# $dest = $src1 IDIV $src2
#
# Preserves all flags
#
idiv r r ri
#
# Arithmetical modulo operation (REM)
#
# $dest = $src1 MOD $src2
#
# Preserves all flags
#
rem r r ri