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-30 13:46:44 +02:00
parent 6b3ac53eb4
commit c79ade6609
No known key found for this signature in database
GPG Key ID: DDF8325C95299A62
11 changed files with 76 additions and 12 deletions

View File

@ -12,7 +12,7 @@ start:
call dir_test
;hlt
hlt
; Wait for and print input indefinitely
.1:

View File

@ -46,7 +46,10 @@ IDT slots:
513-767 maskable hardware interrupts (see ...), OVERRIDES slot 512
768 a handler in this slot will receive all non-maskable hardware interrupts
769-1023 non-maskable hardware interrupts (see ...), OVERRIDES slot 768
769-1022 non-maskable hardware interrupts (see ...), OVERRIDES slot 768
1023 Uncatchable exception, guarantees shutdown. Only throwable by supervisor
via the CRASH instruction, or by the machine in case of irrecoverable failure
A handler for some E/I must use the 'idtdone' iocall to show that it is done dealing with
a certain E/I. If that same E/I happens again before that, the following happens:

View File

@ -10,7 +10,7 @@ It will take registers ax0-ax7 as its parameters, and
return a value in rdx:rax.
The return value in rax is a status value:
≥0 ok (>0 only if meaningful)
≥0 ok (>0 only when meaningful)
-1 unspecified error
-2 no such device
-3 device powered off

View File

@ -6,7 +6,7 @@
#---------------------------------------------------------------------------#
#
# Unconditional jump (JMP) instruction
# Absolute jump (JMP) instruction
#
# RIP = $1
#
@ -14,7 +14,7 @@ j ri
jmp ri
#
# RCX-dependent jump (LOOP) instruction
# RCX-dependent absolute jump (LOOP) instruction
#
# IF (RCX > 0) THEN
# RCX = RCX - 1
@ -22,3 +22,22 @@ jmp ri
# FI
#
loop ri
#
# Relative jump (BCH) instruction ("branch")
#
# RIP = RIP + $1
#
b ri
bch ri
#
# RCX-dependent relative jump (BOOP) instruction
#
# IF (RCX > 0) THEN
# RCX = RCX - 1
# RIP = RIP + $1
# FI
#
boop ri

View File

@ -5,6 +5,18 @@
# Supervisor only instructions #
#---------------------------------------------------------------------------#
#
# Crash virtual machine (CRASH)
#
# THROW #1023
#
# Throws:
# #SYS if not in supervisor mode
# #ILL if disabled through DV
# #1023 otherwise
#
crash
#
# Initiate machine shutdown (STOP)
#

View File

@ -28,3 +28,24 @@ IMPL_START_1(loop)
}
IMPL_END;
IMPL_START_1(b)
{
rip += v1;
}
IMPL_END;
IMPL_START_1(bch)
{
rip += v1;
}
IMPL_END;
IMPL_START_1(boop)
{
if (rcx > 0) {
rcx--;
rip += v1;
}
}
IMPL_END;

View File

@ -13,6 +13,13 @@ IMPL_START_0(stop)
}
IMPL_END;
IMPL_START_0(crash)
{
CHK_SUPERV();
_except(ctx, 1023, "CRASH instruction");
}
IMPL_END;
IMPL_START_0(hlt)
{
CHK_SUPERV();
@ -26,7 +33,11 @@ IMPL_START_0(hlt)
die(0);
if (evt.type == SDL_KEYDOWN)
{
console_handle_input(ctx, evt.key.keysym.sym);
if (evt.key.keysym.sym == SDLK_RETURN)
break;
}
}
}
}

View File

@ -5,7 +5,7 @@
-->
<!DOCTYPE language SYSTEM "language.dtd">
<language _name="Assembler (K-Arch)" version="1.0" _section="Sources" globs="*.k" mimetypes="text/x-asm;text/x-assembler">
<language _name="Assembler (KVISC)" version="1.0" _section="Sources" globs="*.k" mimetypes="text/x-asm;text/x-assembler">
<escape-char>\</escape-char>
@ -56,14 +56,13 @@
<!-- KVISC -->
<keyword>(inv|flg|[re]?pc)</keyword>
<keyword>[a-z]x[0-9]+</keyword>
<keyword>[re][a-z]x</keyword>
<keyword>[re][a-z][xi]l?</keyword>
<keyword>[a-z]x[0-9]+[bwdlq]?</keyword>
<!-- x86-64 -->
<keyword>[c-gs]s</keyword>
<keyword>[re]?flags</keyword>
<keyword>([gil]d)?tr</keyword>
<keyword>[re]?[ds]il?</keyword>
<keyword>[re]?[sbi]pl?</keyword>
<keyword>[x-z]mm[0-9]+</keyword>
<keyword>[re]?[a-d][xhl]</keyword>

View File

@ -32,7 +32,7 @@ void _except(ctx_t *ctx, int _code, char *fmt, ...)
exit(-12);
}
if (code >= IDT_SLOTS)
if (code >= IDT_SLOTS || code == 1023)
goto actually_die;
//

View File

@ -140,7 +140,6 @@ int main(int argc, char **argv)
main_ctx.mz = MEMSIZE;
main_ctx.get = bget;
main_ctx.rf[RIP] = MEMOFF;
if (main_ctx.mp == 0) {

View File

@ -27,7 +27,7 @@ int create_symtab(const char *name)
logerr("Symbol addresses in symbol table not in increasing order\n");
logerr("Previous symbol: '%s' '%lu'\n", symtab[it-1].name, prev_addr);
logerr("Current symbol: '%s' '%lu'\n", buf, addr);
exit(-55);
exit(-1);
}
prev_addr = addr;