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-13 15:47:20 +02:00
parent 92ad76792f
commit eedcd970e5
No known key found for this signature in database
GPG Key ID: 9C7ACF0C053FB8A1
4 changed files with 76 additions and 21 deletions

View File

@ -206,7 +206,7 @@ div2 rim
#---------------------------------------------------------------------------#
#
# TEST Comparaison instruction
# TEST Comparison instruction
#
# $1 AND $2
#
@ -216,7 +216,7 @@ div2 rim
test rim rim
#
# CMP Comparaison instruction
# CMP Comparison instruction
#
# $1 - $2
#
@ -416,6 +416,50 @@ lodsb
lodsb r
lodsb rm r
#
# Scan string for a particular value (SCASx)
#
# CMP([%str], $val)
#
# IF (DF == 0) THEN
# %str = %str + sizeof(x)
# ELSE
# %str = %str - sizeof(x)
# FI
#
# Sets CF, OF, ZF and SF according to the result of the comparison
#
# When no parameters are given, %str = RDI and $val = RAX
# When one parameter is given, %str = RDI and $val = $1
# When two parameters are given, %str = $1 and $val = $2
#
scasb
scasb rim
scasb r rim
#
# Compare bytes in strings (CMPSx)
#
# CMP([%str1], [%str2])
#
# IF (DF == 0) THEN
# %str1 = %str1 + sizeof(x)
# %str2 = %str2 + sizeof(x)
# ELSE
# %str1 = %str1 - sizeof(x)
# %str2 = %str2 - sizeof(x)
# FI
#
# Sets CF, OF, ZF and SF according to the result of the comparison
#
# When no parameters are given, %str1 = RDI and %str2 = RSI
# When one parameter is given, %str1 = RDI and %str2 = $1
# When two parameters are given, %str1 = $1 and %str2 = $2
#
cmpsb
cmpsb r
cmpsb r r
#
# Move value from string to string (MOVSx)
#

View File

@ -100,32 +100,17 @@ IMPL_OUT;
IMPL_START_2(subf)
{
if (v1 < v2) flg |= CF;
else flg &= ~CF;
if ( ((v2 < 0) && (v1 > LONG_MAX + v2))
|| ((v2 > 0) && (v1 < LONG_MIN + v2)) )
flg |= OF;
else flg &= ~OF;
COMPARE(v1, v2);
v1 -= v2;
}
IMPL_OUT_ZSF;
IMPL_OUT;
//
// i_subf but discards result
//
IMPL_START_2(cmp)
{
if (v1 < v2) flg |= CF;
else flg &= ~CF;
if ( ((v2 < 0) && (v1 > LONG_MAX + v2))
|| ((v2 > 0) && (v1 < LONG_MIN + v2)) )
flg |= OF;
else flg &= ~OF;
SET_ZSF(v1 - v2);
COMPARE(v1, v2);
}
IMPL_END;
@ -180,7 +165,6 @@ IMPL_START_2(mulf)
}
IMPL_OUT;
IMPL_START_1(mul2)
{
multiply(rax, v1, &rdx, &rax);

View File

@ -21,3 +21,12 @@
SET_SF(v); \
SET_PF(v)
#define COMPARE(v1, v2) \
if (v1 < v2) flg |= CF; \
else flg &= ~CF; \
if ( ((v2 < 0) && (v1 > LONG_MAX + v2)) \
|| ((v2 > 0) && (v1 < LONG_MIN + v2)) ) \
flg |= OF; \
else flg &= ~OF; \
SET_ZSF(v1 - v2);

View File

@ -10,11 +10,29 @@ IMPL_START_0(stosb)
}
IMPL_END;
//----------------------------------------------------------------------------//
IMPL_START_0(lodsb)
{
}
IMPL_END;
//----------------------------------------------------------------------------//
IMPL_START_0(scasb)
{
}
IMPL_END;
//----------------------------------------------------------------------------//
IMPL_START_0(cmpsb)
{
}
IMPL_END;
//----------------------------------------------------------------------------//
IMPL_START_0(movsb)
{
}