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
|
|
|
#---------------------------------------------------------------------------#
|
|
|
|
# Logical instructions #
|
|
|
|
#---------------------------------------------------------------------------#
|
|
|
|
|
|
|
|
#
|
|
|
|
# TEST Comparison instruction
|
|
|
|
#
|
|
|
|
# $1 AND $2
|
|
|
|
#
|
|
|
|
# Clears OF and CF
|
|
|
|
# Sets ZF and SF according to the result
|
|
|
|
#
|
|
|
|
test r ri
|
|
|
|
|
|
|
|
#
|
|
|
|
# Bitwise NOT operation
|
|
|
|
#
|
|
|
|
# $1 = NOT($2)
|
|
|
|
#
|
|
|
|
# Preserves all flags
|
|
|
|
#
|
|
|
|
not r r
|
|
|
|
|
|
|
|
#
|
|
|
|
# Bitwise OR operation
|
|
|
|
#
|
|
|
|
# $dest = $src1 OR $src2
|
|
|
|
#
|
|
|
|
# Preserves all flags
|
|
|
|
#
|
|
|
|
or r ri
|
|
|
|
or r r ri
|
|
|
|
or m ri
|
|
|
|
or m r ri
|
|
|
|
|
|
|
|
# $dest = $src1 OR NOT($src2)
|
|
|
|
orn r ri
|
|
|
|
orn r r ri
|
|
|
|
|
|
|
|
# $dest = NOT($src1 OR $src2)
|
|
|
|
nor r r ri
|
|
|
|
|
|
|
|
#
|
|
|
|
# Bitwise AND operation
|
|
|
|
#
|
|
|
|
# $dest = $src1 AND $src2
|
|
|
|
#
|
|
|
|
# Preserves all flags
|
|
|
|
#
|
|
|
|
and r rim
|
|
|
|
and r r rim
|
|
|
|
and m ri
|
|
|
|
and m r ri
|
|
|
|
|
|
|
|
# $dest = $src1 AND NOT($src2)
|
|
|
|
andn r r ri
|
|
|
|
|
|
|
|
# $dest = NOT($src1 AND $src2)
|
|
|
|
nand r r ri
|
|
|
|
|
|
|
|
#
|
|
|
|
# Bitwise XOR operation
|
|
|
|
#
|
|
|
|
# $dest = $src1 XOR $src2
|
|
|
|
#
|
|
|
|
# Preserves all flags
|
|
|
|
#
|
|
|
|
xor r rim
|
|
|
|
xor r r rim
|
|
|
|
xor m ri
|
|
|
|
xor m r ri
|
|
|
|
|
|
|
|
# $dest = $src1 XOR NOT($src2)
|
|
|
|
xorn r r ri
|
|
|
|
|
|
|
|
# $dest = NOT($src1 XOR $src2)
|
|
|
|
xnor 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
|
|
|
|
|
2019-06-23 12:40:18 +02:00
|
|
|
#---------------------------------------------------------------------------#
|
|
|
|
# Arithmetic instructions #
|
|
|
|
#---------------------------------------------------------------------------#
|
|
|
|
|
|
|
|
#
|
|
|
|
# CMP Comparison instruction
|
|
|
|
#
|
|
|
|
# $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
|
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
cmp r ri
|
|
|
|
cmp m ri
|
2019-06-23 12:40:18 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Arithmetical SGN operation
|
|
|
|
#
|
|
|
|
# IF ($1 == 0) THEN
|
|
|
|
# $2 = 0
|
|
|
|
# ELIF ($1 GT 0) THEN
|
|
|
|
# $2 = 1
|
|
|
|
# ELSE
|
|
|
|
# $2 = LONG_MIN
|
|
|
|
# FI
|
|
|
|
#
|
|
|
|
# Treats $1 and $2 as signed values
|
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
# Preserves all flags
|
|
|
|
#
|
|
|
|
sgn r r
|
2019-06-23 12:40:18 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Arithmetical NEG operation
|
|
|
|
#
|
2019-07-04 18:41:05 +02:00
|
|
|
# $1 = NOT($2) + 1
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
# Preserves all flags
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
neg r r
|
2019-06-23 12:40:18 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Arithmetical INC operation
|
|
|
|
#
|
|
|
|
# $1 = $1 + 1
|
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
# Preserves all flags
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
|
|
|
inc rm
|
|
|
|
|
|
|
|
#
|
|
|
|
# Arithmetical DEC operation
|
|
|
|
#
|
|
|
|
# $1 = $1 - 1
|
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
# Preserves all flags
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
|
|
|
dec rm
|
|
|
|
|
|
|
|
#
|
|
|
|
# Arithmetical ADD operation
|
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
# $dest1 = $src1 + $src2
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
add r rim
|
|
|
|
add r r ri
|
|
|
|
add m ri
|
|
|
|
|
|
|
|
addf r r ri
|
2019-07-17 20:26:03 +02:00
|
|
|
addo r r ri
|
2019-06-23 12:40:18 +02:00
|
|
|
|
2019-07-04 18:41:05 +02:00
|
|
|
#
|
|
|
|
# Atomic exchange and add (XADD)
|
|
|
|
#
|
|
|
|
# $tmp = $1
|
|
|
|
# $1 = $1 + $2
|
|
|
|
# $2 = $1
|
|
|
|
#
|
|
|
|
# Preserves all flags
|
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
xadd r rm
|
|
|
|
xadd m r
|
2019-07-04 18:41:05 +02:00
|
|
|
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
# Arithmetical SUB operation
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
# $dest = $src1 - $src2
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
sub r rim
|
|
|
|
sub r r ri
|
2019-07-06 21:59:08 +02:00
|
|
|
sub r i r
|
2019-07-04 20:33:49 +02:00
|
|
|
sub m ri
|
|
|
|
|
|
|
|
subf r r ri
|
2019-07-06 21:59:08 +02:00
|
|
|
subf r i r
|
2019-07-17 20:26:03 +02:00
|
|
|
subo r r ri
|
|
|
|
subo r i r
|
2019-06-23 12:40:18 +02:00
|
|
|
|
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
# Arithmetical ADD/SUB operation, with carry/overflow
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
# $dest = $src1 + $src2 + CF (ADC)
|
|
|
|
# $dest = $src1 + $src2 + OF (ADO)
|
|
|
|
# $dest = $src1 - $src2 - CF (SBB)
|
|
|
|
# $dest = $src1 - $src2 - OF (SBO)
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
# Preserves ZF and SF
|
|
|
|
# Flags CF and OF are undefined for now
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
2019-07-17 20:26:03 +02:00
|
|
|
adcx r r ri
|
|
|
|
adox r r ri
|
|
|
|
sbbx r r ri
|
|
|
|
sbox r r ri
|
2019-06-23 12:40:18 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Arithmetical unsigned MUL operation
|
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
# $dest = LO($src1 * $src2)
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
|
|
|
# Preserves ZF and SF
|
2019-07-04 20:33:49 +02:00
|
|
|
# Sets CF and OF if HI($src1 * $src2) > 0, clears them otherwise
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
mul r r ri
|
|
|
|
mulf r r ri
|
2019-07-17 20:26:03 +02:00
|
|
|
mulo r r ri
|
2019-06-23 12:40:18 +02:00
|
|
|
|
2019-07-04 20:33:49 +02:00
|
|
|
# Arithmetical unsigned MUL operation
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
# $dest1 = HI($dest2 * $src)
|
|
|
|
# $dest2 = LO($dest2 * $src)
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
2019-07-04 18:41:05 +02:00
|
|
|
# Sets CF and OF if HI($2 * $3) > 0, clears them otherwise
|
|
|
|
# Preserves ZF and SF
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
mulhi r r ri
|
2019-06-23 12:40:18 +02:00
|
|
|
|
|
|
|
#
|
2019-07-04 18:41:05 +02:00
|
|
|
# Arithmetical unsigned DIV operation
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
# $dest1 = $1 DIV $2
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
2019-07-04 18:41:05 +02:00
|
|
|
# Preserves all flags
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
div r r ri
|
2019-06-23 12:40:18 +02:00
|
|
|
|
|
|
|
#
|
2019-07-04 18:41:05 +02:00
|
|
|
# Arithmetical unsigned modulo operation (REM)
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
2019-07-04 18:41:05 +02:00
|
|
|
# $1 = $1 MOD $2
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
|
|
|
# Preserves all flags
|
|
|
|
#
|
2019-07-04 20:33:49 +02:00
|
|
|
rem r r ri
|
2019-06-23 12:40:18 +02:00
|
|
|
|