mirror of
https://gitlab.os-k.eu/os-k-team/kvisc.git
synced 2023-08-25 14:05:46 +02:00
vm
This commit is contained in:
parent
2a610f2d7a
commit
5b315ad46a
@ -11,7 +11,7 @@ FILE_LOADP := 0x141000 ; 4KB above stack
|
||||
start:
|
||||
mov rsp, 0x140000
|
||||
mov rbp, zero
|
||||
|
||||
|
||||
cls
|
||||
cld
|
||||
call main
|
||||
|
@ -10,8 +10,14 @@
|
||||
; <0 if the first character that does not match has a lower value in str1 than in str2
|
||||
;
|
||||
strcmp:
|
||||
mov ax2, STRLEN_MAX
|
||||
jmp strncmp
|
||||
mov rcx, STRLEN_MAX
|
||||
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)
|
||||
|
@ -114,7 +114,7 @@ trap0_handler:
|
||||
jmp .fini
|
||||
|
||||
.handle_ReadFile:
|
||||
add ax1, ax0, nx0
|
||||
add ax1, ax1, nx0
|
||||
call DISK.ReadFile
|
||||
jmp .fini
|
||||
|
||||
|
@ -130,6 +130,12 @@ main:
|
||||
call strcmp
|
||||
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"
|
||||
mov ax0, argv0
|
||||
mov ax1, .builtin_echo
|
||||
@ -198,6 +204,10 @@ main:
|
||||
call builtins.dir
|
||||
jmp .print_prompt
|
||||
|
||||
.handle_DUMP:
|
||||
dump
|
||||
jmp .print_prompt
|
||||
|
||||
.handle_ECHO:
|
||||
mov rdx, q[argv1pos]
|
||||
b.z rdx, 0, .echo.end
|
||||
@ -275,6 +285,8 @@ main:
|
||||
prns.rep.nz rdx
|
||||
mov rdx, .helpmsg.dir
|
||||
prns.rep.nz rdx
|
||||
mov rdx, .helpmsg.dump
|
||||
prns.rep.nz rdx
|
||||
mov rdx, .helpmsg.echo
|
||||
prns.rep.nz rdx
|
||||
mov rdx, .helpmsg.exit
|
||||
@ -294,6 +306,7 @@ main:
|
||||
.helpmsg.cls = " CLS Clear screen\n"
|
||||
.helpmsg.date = " DATE Display current date\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.exit = " EXIT Initiate machine shutdown\n"
|
||||
.helpmsg.help = " HELP Display these messages\n"
|
||||
|
13
vm/in/ALU
13
vm/in/ALU
@ -23,7 +23,6 @@ not r r
|
||||
#
|
||||
or r r ri
|
||||
# $dest = $src1 OR NOT($src2)
|
||||
orn r ri
|
||||
orn r r ri
|
||||
# $dest = NOT($src1 OR $src2)
|
||||
nor r r ri
|
||||
@ -149,18 +148,6 @@ add r r ri
|
||||
addf 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
|
||||
#
|
||||
|
10
vm/in/MISC
10
vm/in/MISC
@ -14,15 +14,11 @@
|
||||
break
|
||||
|
||||
#
|
||||
# Enable/disable instruction dumping (DUMP)
|
||||
# Toggles instruction dumping (DUMP)
|
||||
#
|
||||
# IF $1 == 0 THEN
|
||||
# (disable instruction dumping)
|
||||
# ELSE
|
||||
# (enable instruction dumping)
|
||||
# FI
|
||||
# (toggles instruction dumping)
|
||||
#
|
||||
dump ri
|
||||
dump
|
||||
|
||||
#---------------------------------------------------------------------------#
|
||||
# Misc. instructions #
|
||||
|
@ -39,7 +39,6 @@ IMPL_START_1(dec) { v1--; } 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(addo) { COMPARE(v2, ~v3+1); v1 = v2 + v3; INTO(); } IMPL_OUT;
|
||||
|
||||
|
11
vm/in/misc.c
11
vm/in/misc.c
@ -30,20 +30,17 @@ IMPL_START_0(break)
|
||||
}
|
||||
IMPL_END;
|
||||
|
||||
IMPL_START_1(dump)
|
||||
IMPL_START_0(dump)
|
||||
{
|
||||
(void)v1;
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (ctx->dumpsw && !v1)
|
||||
if (ctx->dumpsw)
|
||||
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);
|
||||
|
||||
ctx->dumpsw = !!v1;
|
||||
ctx->dumpsw = !ctx->dumpsw;
|
||||
#endif
|
||||
|
||||
}
|
||||
IMPL_END;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user