1
0
mirror of https://gitlab.os-k.eu/os-k-team/kvisc.git synced 2023-08-25 14:05:46 +02:00

string instrs doc

This commit is contained in:
julianb0 2019-06-13 15:32:24 +02:00
parent 434e3ff63d
commit 92ad76792f
No known key found for this signature in database
GPG Key ID: 9C7ACF0C053FB8A1
3 changed files with 94 additions and 3 deletions

View File

@ -380,6 +380,62 @@ leave
# String manipulation instructions #
#---------------------------------------------------------------------------#
#
# Store value into string (STOSx)
#
# [%str] = $val
# IF (DF == 0) THEN
# %str = %str + sizeof(x)
# ELSE
# %str = %str - sizeof(x)
# FI
#
# 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
#
stosb
stosb rim
stosb r rim
#
# Load value from string (LODSx)
#
# %dest = [%str]
# IF (DF == 0) THEN
# %str = %str + sizeof(x)
# ELSE
# %str = %str - sizeof(x)
# FI
#
# When no parameters are given, %str = RDI and %dest = RAX
# When one parameter is given, %str = RDI and %dest = $1
# When two parameters are given, %str = $2 and %dest = $1
#
lodsb
lodsb r
lodsb rm r
#
# Move value from string to string (MOVSx)
#
# [%str1] = [%str2]
# IF (DF == 0) THEN
# %str1 = %str1 + sizeof(x)
# %str2 = %str2 + sizeof(x)
# ELSE
# %str1 = %str1 - sizeof(x)
# %str2 = %str2 - sizeof(x)
# FI
#
# 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
#
movsb
movsb r
movsb r r
#---------------------------------------------------------------------------#
# Supervisor only instructions #
#---------------------------------------------------------------------------#

24
vm/in/string.c Normal file
View File

@ -0,0 +1,24 @@
// 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_0(stosb)
{
}
IMPL_END;
IMPL_START_0(lodsb)
{
}
IMPL_END;
IMPL_START_0(movsb)
{
}
IMPL_END;
//----------------------------------------------------------------------------//

View File

@ -304,11 +304,15 @@ void exec_instr(ctx_t *ctx,
// Debugging
dump_instr(ctx, in, p1, p2, lock, rep, cond, pc);
do_rep:
if (!eval_cond(ctx, cond))
//
// For REPs we evaluate the condition AFTER running the instruction,
// in a do ... while(cond) fashion
//
if (!rep && !eval_cond(ctx, cond))
return;
do_rep:
out = in->func(ctx, p1, p2, &r1, &r2);
if (out)
@ -343,6 +347,13 @@ do_rep:
if (rep && rcx > 0)
{
// RCX remains untouched when condition fails
if (!eval_cond(ctx, cond))
return;
// Show that we're REP'ing
dump_instr(ctx, in, p1, p2, lock, rep, cond, pc);
rcx--;
goto do_rep;
}