1
0
mirror of https://gitlab.os-k.eu/os-k-team/kvisc.git synced 2023-08-25 14:05:46 +02:00
This commit is contained in:
julianb0 2019-06-16 13:06:41 +02:00
parent ee4f983103
commit a48473df92
No known key found for this signature in database
GPG Key ID: DDF8325C95299A62
4 changed files with 81 additions and 1 deletions

View File

@ -5,7 +5,10 @@
; Main function ; Main function
; ;
main: main:
call movzx_test jmp bswap_test
bswap_test:
mov rdx, 0xFFEEDDCCBBAA99884433
ret ret
ramdev_test: ramdev_test:

View File

@ -138,6 +138,18 @@ decf rm
add rm rim add rm rim
addf rm rim addf rm rim
#
# 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 # Arithmetical SUB operation
# #
@ -507,6 +519,20 @@ cmc
clc clc
stc stc
#---------------------------------------------------------------------------#
# Byte-wise / bit-wise manipulation instructions #
#---------------------------------------------------------------------------#
#
# Byte/word/dword swap (xSWAP)
#
# Changes endianness
#
bswap rm rim
wswap rm rim
dswap rm rim
#---------------------------------------------------------------------------# #---------------------------------------------------------------------------#
# Misc. instructions # # Misc. instructions #
#---------------------------------------------------------------------------# #---------------------------------------------------------------------------#

View File

@ -93,6 +93,30 @@ IMPL_START_2(addf)
} }
IMPL_OUT_ZSF; IMPL_OUT_ZSF;
IMPL_START_2(adc)
{
v1 += v2 + !!(flg&CF);
}
IMPL_OUT;
IMPL_START_2(adcf)
{
if (v1 + v2 + !!(flg&CF) < v1) flg |= OF;
else flg &= ~OF;
v1 += !!(flg&CF);
if ( ((v2 > 0) && (v1 > LONG_MAX - v2))
|| ((v2 < 0) && (v1 < LONG_MIN - v2)) )
flg |= CF;
else flg &= ~CF;
v1 += v2;
}
IMPL_OUT_ZSF;
//--------------------------------------------------------------------------
IMPL_START_2(sub) IMPL_START_2(sub)
{ {
v1 -= v2; v1 -= v2;

27
vm/in/misc.c Normal file
View File

@ -0,0 +1,27 @@
// The OS/K Team licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#include <in/instrs.h>
IMPL_START_2(bswap)
{
v1 = ((v2 & 0xFF00000000000000) >> 56)
| ((v2 & 0x00FF000000000000) >> 40)
| ((v2 & 0x0000FF0000000000) >> 24)
| ((v2 & 0x000000FF00000000) >> 8)
| ((v2 & 0x00000000FF000000) << 8)
| ((v2 & 0x0000000000FF0000) << 24)
| ((v2 & 0x000000000000FF00) << 40)
| ((v2 & 0x00000000000000FF) << 56);
}
IMPL_OUT;
IMPL_START_2(wswap)
{
}
IMPL_OUT;
IMPL_START_2(dswap)
{
}
IMPL_OUT;