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
89ed8fdc0d
commit
06345cfa78
28
as/k-as.py
28
as/k-as.py
@ -449,7 +449,7 @@ def parse_instr(line):
|
||||
else:
|
||||
params = None
|
||||
|
||||
size = 2
|
||||
size = 1
|
||||
|
||||
# Byte 2 (rep|lock|0|cond)
|
||||
b2 = 0
|
||||
@ -478,7 +478,12 @@ def parse_instr(line):
|
||||
instr_args = ''
|
||||
|
||||
if params == None or len(params) == 0:
|
||||
instrs.write("{} %%imm8 {}".format(instr_name, b2))
|
||||
if b2 == 0:
|
||||
instrs.write("{}".format(instr_name))
|
||||
|
||||
else:
|
||||
size += 1
|
||||
instrs.write("%%suff {} %%imm8 {}".format(instr_name, b2))
|
||||
|
||||
return size
|
||||
|
||||
@ -637,7 +642,8 @@ def parse_instr(line):
|
||||
|
||||
# [reg+reg*imm+imm]
|
||||
else:
|
||||
instr_args += "%%imm8 {} {} {} %%imm8 {} %%signed %%imm32 {}".format(fmts["m_rrii"]|mlen, reg1, reg2, imm1, imm2)
|
||||
instr_args += "%%imm8 {} {} {} %%imm8 {} %%signed %%imm32 {}"\
|
||||
.format(fmts["m_rrii"]|mlen, reg1, reg2, imm1, imm2)
|
||||
size += 8
|
||||
|
||||
# [reg]
|
||||
@ -711,13 +717,19 @@ def parse_instr(line):
|
||||
|
||||
instr_args += word
|
||||
|
||||
instrs.write("{} %%imm8 {} {}".format(instr_name, b2, instr_args))
|
||||
if b2 == 0:
|
||||
instrs.write("{} {}".format(instr_name, instr_args))
|
||||
|
||||
else:
|
||||
size += 1
|
||||
instrs.write("%%suff {} %%imm8 {} {}".format(instr_name, b2, instr_args))
|
||||
|
||||
return size
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
special_syms = {
|
||||
"%%suff",
|
||||
"%%imm8",
|
||||
"%%imm16",
|
||||
"%%imm32",
|
||||
@ -733,6 +745,7 @@ def gentext():
|
||||
data_start += (8 - data_start % 8)
|
||||
|
||||
instrs.seek(0)
|
||||
suff_mask = 0
|
||||
|
||||
for _, line in enumerate(instrs):
|
||||
tok = line.strip().split()
|
||||
@ -752,8 +765,9 @@ def gentext():
|
||||
continue
|
||||
|
||||
if word in pinstrs:
|
||||
idx = pinstrs.index(word)
|
||||
idx = pinstrs.index(word) | suff_mask
|
||||
b_text.write(idx.to_bytes(1, byteorder='little', signed=False))
|
||||
suff_mask = 0
|
||||
continue
|
||||
|
||||
if word in plabels_text:
|
||||
@ -767,7 +781,9 @@ def gentext():
|
||||
continue
|
||||
|
||||
if word in special_syms:
|
||||
if word == "%%imm8":
|
||||
if word == "%%suff":
|
||||
suff_mask = 1<<7
|
||||
elif word == "%%imm8":
|
||||
lastimm = 1
|
||||
elif word == "%%imm16":
|
||||
lastimm = 2
|
||||
|
@ -24,8 +24,9 @@ WORD_MAX := 0x000000000000FFFF
|
||||
LWORD_MAX := 0x00000000FFFFFFFF
|
||||
QWORD_MAX := 0xFFFFFFFFFFFFFFFF
|
||||
|
||||
STRLEN_MAX := 0x000000007AFFFFFF
|
||||
FILE_MAXSZ := 0x0000000000008000
|
||||
STRLEN_MAX := 0x000000007AFFFFFF
|
||||
FNAME_MAX := 0x0000000000000080
|
||||
|
||||
;
|
||||
; Magic numbers
|
||||
|
@ -1,8 +1,6 @@
|
||||
; The OS/K Team licenses this file to you under the MIT license.
|
||||
; See the LICENSE file in the project root for more information.
|
||||
|
||||
NAME_MAX := 256
|
||||
|
||||
builtins.dir:
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
@ -17,7 +15,7 @@ builtins.dir:
|
||||
.first:
|
||||
mov rax, Sys.FindFirst
|
||||
mov ax0, .buf
|
||||
mov ax1, NAME_MAX
|
||||
mov ax1, FNAME_MAX
|
||||
trap 0
|
||||
|
||||
jmp .list
|
||||
@ -25,7 +23,7 @@ builtins.dir:
|
||||
.next:
|
||||
mov rax, Sys.FindNext
|
||||
mov ax0, .buf
|
||||
mov ax1, NAME_MAX
|
||||
mov ax1, FNAME_MAX
|
||||
trap 0
|
||||
|
||||
.list:
|
||||
@ -35,7 +33,7 @@ builtins.dir:
|
||||
inc r12, 1
|
||||
|
||||
; separate extension from file name
|
||||
mov rcx, NAME_MAX
|
||||
mov rcx, FNAME_MAX
|
||||
mov rsi, .buf
|
||||
mov rdi, rsi
|
||||
scasb.rep.nz rsi, '.'
|
||||
@ -111,7 +109,7 @@ builtins.dir:
|
||||
leave
|
||||
ret
|
||||
|
||||
.buf = [256]
|
||||
.buf = [FNAME_MAX]
|
||||
.endstr1 = " %d file(s)\n"
|
||||
.endstr2 = " 0 dir(s)\n"
|
||||
|
||||
|
@ -208,7 +208,16 @@ void decode(ctx_t *ctx)
|
||||
|
||||
// Instruction bytes
|
||||
b1 = fetchb(ctx);
|
||||
|
||||
// Suffixes?
|
||||
if (b1 & (1 << 7))
|
||||
{
|
||||
b1 &= ~(1 << 7);
|
||||
b2 = fetchb(ctx);
|
||||
}
|
||||
|
||||
else
|
||||
b2 = 0;
|
||||
|
||||
// Renge check
|
||||
if (b1 >= NINSTRS)
|
||||
|
@ -36,10 +36,6 @@ jmp_buf exc_jmp_buf;
|
||||
//
|
||||
void main_loop(void)
|
||||
{
|
||||
/*
|
||||
if (main_ctx.dumpsw)
|
||||
trace("\n\n\n");
|
||||
*/
|
||||
setjmp(exc_jmp_buf);
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user