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.
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
cmp rim rim
|
|
|
|
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
# Sets ZF and SF according to the result
|
|
|
|
#
|
|
|
|
sgn rm rim
|
|
|
|
sgnf rm rim
|
|
|
|
|
|
|
|
#
|
|
|
|
# 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 18:41:05 +02:00
|
|
|
# Sets CF if $2 == 0; clears it otherwise
|
|
|
|
# Sets OF if $2 == $LONG_MIN; clears it otherwise
|
2019-06-23 12:40:18 +02:00
|
|
|
# Sets ZF and SF according to the result
|
|
|
|
#
|
2019-07-04 18:41:05 +02:00
|
|
|
neg rm rim
|
|
|
|
negf rm rim
|
2019-06-23 12:40:18 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Arithmetical INC operation
|
|
|
|
#
|
|
|
|
# $1 = $1 + 1
|
|
|
|
#
|
|
|
|
# Preserves CF
|
|
|
|
# Sets OF if $1 == $LONG_MAX, clears it otherwise
|
|
|
|
# Sets ZF and SF according to the result
|
|
|
|
#
|
|
|
|
inc rm
|
|
|
|
incf rm
|
|
|
|
|
|
|
|
#
|
|
|
|
# Arithmetical DEC operation
|
|
|
|
#
|
|
|
|
# $1 = $1 - 1
|
|
|
|
#
|
|
|
|
# Preserves CF
|
|
|
|
# Sets OF if $1 == $LONG_MIN, clears it otherwise
|
|
|
|
# Sets ZF and SF according to the result
|
|
|
|
#
|
|
|
|
dec rm
|
|
|
|
decf rm
|
|
|
|
|
|
|
|
#
|
|
|
|
# Arithmetical ADD operation
|
|
|
|
#
|
|
|
|
# $1 = $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
|
|
|
|
#
|
|
|
|
add rm rim
|
|
|
|
addf rm rim
|
|
|
|
|
2019-07-04 18:41:05 +02:00
|
|
|
#
|
|
|
|
# Atomic exchange and add (XADD)
|
|
|
|
#
|
|
|
|
# $tmp = $1
|
|
|
|
# $1 = $1 + $2
|
|
|
|
# $2 = $1
|
|
|
|
#
|
|
|
|
# Preserves all flags
|
|
|
|
#
|
|
|
|
xadd rm rm
|
|
|
|
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
|
|
|
# Arithmetical ADD operation, with carry
|
|
|
|
#
|
|
|
|
# $1 = $1 + $2 + CF
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
adc rm rim
|
|
|
|
adcf rm rim
|
|
|
|
|
|
|
|
#
|
|
|
|
# Arithmetical SUB operation
|
|
|
|
#
|
|
|
|
# $1 = $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
|
|
|
|
#
|
|
|
|
sub rm rim
|
|
|
|
subf rm rim
|
|
|
|
|
|
|
|
#
|
|
|
|
# Arithmetical unsigned MUL operation
|
|
|
|
#
|
|
|
|
# $1 = LO($1 * $2)
|
|
|
|
#
|
|
|
|
# Sets CF and OF if HI($1 * $2) > 0, clears them otherwise
|
|
|
|
# Preserves ZF and SF
|
|
|
|
#
|
|
|
|
mul rm rim
|
|
|
|
mulf rm rim
|
|
|
|
|
|
|
|
#
|
2019-07-04 18:41:05 +02:00
|
|
|
# Arithmetical unsigned 128-bit MUL operation
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
2019-07-04 18:41:05 +02:00
|
|
|
# $1 = HI($2 * $3)
|
|
|
|
# $2 = LO($2 * $3)
|
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 18:41:05 +02:00
|
|
|
mulx rm rm rim
|
|
|
|
mulfx rm rm rim
|
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 18:41:05 +02:00
|
|
|
# $1 = $1 DIV $2
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
|
|
|
# Preserves all flags
|
|
|
|
#
|
2019-07-04 18:41:05 +02:00
|
|
|
div rm rim
|
2019-06-23 12:40:18 +02:00
|
|
|
|
|
|
|
#
|
2019-07-04 18:41:05 +02:00
|
|
|
# Arithmetical unsigned combined DIV and MOD operations
|
2019-06-23 12:40:18 +02:00
|
|
|
#
|
2019-07-04 18:41:05 +02:00
|
|
|
# $1 = ($2 MOD $3)
|
|
|
|
# $2 = ($2 DIV $3)
|
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 18:41:05 +02:00
|
|
|
divx rm rm rim
|
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 18:41:05 +02:00
|
|
|
rem rm rim
|
2019-06-23 12:40:18 +02:00
|
|
|
|