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-07-17 22:40:13 +02:00
parent 2a610f2d7a
commit 5b315ad46a
No known key found for this signature in database
GPG Key ID: DDF8325C95299A62
8 changed files with 30 additions and 32 deletions

View File

@ -10,8 +10,14 @@
; <0 if the first character that does not match has a lower value in str1 than in str2 ; <0 if the first character that does not match has a lower value in str1 than in str2
; ;
strcmp: strcmp:
mov ax2, STRLEN_MAX mov rcx, STRLEN_MAX
jmp strncmp cmpzsb.rep.z ax0, ax1
mov rax, b[ax0-1]
mov rcx, b[ax1-1]
sub rax, rax, rcx
ret
; ;
; int strncmp(const char *str1, const char *str2, int maxn) ; int strncmp(const char *str1, const char *str2, int maxn)

View File

@ -114,7 +114,7 @@ trap0_handler:
jmp .fini jmp .fini
.handle_ReadFile: .handle_ReadFile:
add ax1, ax0, nx0 add ax1, ax1, nx0
call DISK.ReadFile call DISK.ReadFile
jmp .fini jmp .fini

View File

@ -130,6 +130,12 @@ main:
call strcmp call strcmp
b.z rax, 0, .handle_DIR b.z rax, 0, .handle_DIR
.builtin_dump = "dump"
mov ax0, argv0
mov ax1, .builtin_dump
call strcmp
b.z rax, 0, .handle_DUMP
.builtin_echo = "echo" .builtin_echo = "echo"
mov ax0, argv0 mov ax0, argv0
mov ax1, .builtin_echo mov ax1, .builtin_echo
@ -198,6 +204,10 @@ main:
call builtins.dir call builtins.dir
jmp .print_prompt jmp .print_prompt
.handle_DUMP:
dump
jmp .print_prompt
.handle_ECHO: .handle_ECHO:
mov rdx, q[argv1pos] mov rdx, q[argv1pos]
b.z rdx, 0, .echo.end b.z rdx, 0, .echo.end
@ -275,6 +285,8 @@ main:
prns.rep.nz rdx prns.rep.nz rdx
mov rdx, .helpmsg.dir mov rdx, .helpmsg.dir
prns.rep.nz rdx prns.rep.nz rdx
mov rdx, .helpmsg.dump
prns.rep.nz rdx
mov rdx, .helpmsg.echo mov rdx, .helpmsg.echo
prns.rep.nz rdx prns.rep.nz rdx
mov rdx, .helpmsg.exit mov rdx, .helpmsg.exit
@ -294,6 +306,7 @@ main:
.helpmsg.cls = " CLS Clear screen\n" .helpmsg.cls = " CLS Clear screen\n"
.helpmsg.date = " DATE Display current date\n" .helpmsg.date = " DATE Display current date\n"
.helpmsg.dir = " DIR Print contents of current directory\n" .helpmsg.dir = " DIR Print contents of current directory\n"
.helpmsg.dump = " DUMP Toggles debug instruction dumping\n"
.helpmsg.echo = " ECHO Write arguments to standard output\n" .helpmsg.echo = " ECHO Write arguments to standard output\n"
.helpmsg.exit = " EXIT Initiate machine shutdown\n" .helpmsg.exit = " EXIT Initiate machine shutdown\n"
.helpmsg.help = " HELP Display these messages\n" .helpmsg.help = " HELP Display these messages\n"

View File

@ -23,7 +23,6 @@ not r r
# #
or r r ri or r r ri
# $dest = $src1 OR NOT($src2) # $dest = $src1 OR NOT($src2)
orn r ri
orn r r ri orn r r ri
# $dest = NOT($src1 OR $src2) # $dest = NOT($src1 OR $src2)
nor r r ri nor r r ri
@ -149,18 +148,6 @@ add r r ri
addf r r ri addf r r ri
addo r r ri addo r r ri
#
# Atomic exchange and add (XADD)
#
# $tmp = $1
# $1 = $1 + $2
# $2 = $1
#
# Preserves all flags
#
xadd r rm
xadd m r
# #
# Arithmetical SUB operation # Arithmetical SUB operation
# #

View File

@ -14,15 +14,11 @@
break break
# #
# Enable/disable instruction dumping (DUMP) # Toggles instruction dumping (DUMP)
# #
# IF $1 == 0 THEN # (toggles instruction dumping)
# (disable instruction dumping)
# ELSE
# (enable instruction dumping)
# FI
# #
dump ri dump
#---------------------------------------------------------------------------# #---------------------------------------------------------------------------#
# Misc. instructions # # Misc. instructions #

View File

@ -39,7 +39,6 @@ IMPL_START_1(dec) { v1--; } IMPL_OUT;
//----------------------------------------------------------------------------// //----------------------------------------------------------------------------//
IMPL_START_3(add) { v1 = v2 + v3; } IMPL_OUT; IMPL_START_3(add) { v1 = v2 + v3; } IMPL_OUT;
IMPL_START_2(xadd) { ulong tmp = v1; v1 += v2; v2 = tmp; } IMPL_OUT_2;
IMPL_START_3(addf) { COMPARE(v2, ~v3+1); v1 = v2 + v3; } IMPL_OUT; IMPL_START_3(addf) { COMPARE(v2, ~v3+1); v1 = v2 + v3; } IMPL_OUT;
IMPL_START_3(addo) { COMPARE(v2, ~v3+1); v1 = v2 + v3; INTO(); } IMPL_OUT; IMPL_START_3(addo) { COMPARE(v2, ~v3+1); v1 = v2 + v3; INTO(); } IMPL_OUT;

View File

@ -30,20 +30,17 @@ IMPL_START_0(break)
} }
IMPL_END; IMPL_END;
IMPL_START_1(dump) IMPL_START_0(dump)
{ {
(void)v1;
#ifndef NDEBUG #ifndef NDEBUG
if (ctx->dumpsw && !v1) if (ctx->dumpsw)
trace("0x%lX:\t...\n", rpc); trace("0x%lX:\t...\n", rpc);
else if (!ctx->dumpsw && v1) else if (!ctx->dumpsw)
dump_instr(ctx, ctx->cur_in, p1, p2, p3, 0, 0); dump_instr(ctx, ctx->cur_in, p1, p2, p3, 0, 0);
ctx->dumpsw = !!v1; ctx->dumpsw = !ctx->dumpsw;
#endif #endif
} }
IMPL_END; IMPL_END;