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-16 11:58:12 +02:00
parent 8796f78bf5
commit c2e412fb7f
No known key found for this signature in database
GPG Key ID: DDF8325C95299A62
4 changed files with 19 additions and 14 deletions

View File

@ -679,8 +679,8 @@ special_syms = {
def gentext(): def gentext():
instrs.seek(0) instrs.seek(0)
# print(instrs.read()) print(instrs.read())
# instrs.seek(0) instrs.seek(0)
text_start = 0x100000 text_start = 0x100000
data_start = text_start + ptext data_start = text_start + ptext

6
ka/ABI
View File

@ -19,7 +19,7 @@ A function's assembly code looks like this:
'N' is the number of local variables used by the function, 'N' is the number of local variables used by the function,
and is omitted if there are none ('enter' alone takes N=0). and is omitted if there are none ('enter' alone takes N=0).
The above code is equivalent to the following, but faster: The above code is equivalent to the following, but much faster:
label: label:
mov [rsp-8], rbp mov [rsp-8], rbp
lea rbp, [rsp-8] lea rbp, [rsp-8]
@ -27,8 +27,8 @@ The above code is equivalent to the following, but faster:
... ...
... ...
... ...
lea rsp, [rbp] lea rsp, [rbp+8]
mov rbp, [rsp] mov rbp, [rbp]
ret ret
Between the 'enter' and the 'leave', the stack looks like this: Between the 'enter' and the 'leave', the stack looks like this:

View File

@ -8,6 +8,9 @@ _start:
mov rsp, 0x200000 mov rsp, 0x200000
xor rbp, rbp xor rbp, rbp
__push 11
__pop rbi
call main call main
.1: .1:

View File

@ -48,12 +48,6 @@ for _, line in enumerate(fi):
if len(tok) == 0: if len(tok) == 0:
continue continue
cond = False
if tok[0][0] == '!':
#assert(len(tok[0]) > 1)
#tok[0] = tok[0][1:]
continue
i = tok[0].strip() i = tok[0].strip()
if len(tok) == 1: if len(tok) == 1:
@ -77,6 +71,14 @@ fp.seek(0)
for _, line in enumerate(fp): for _, line in enumerate(fp):
tok = line.strip().split(' ') tok = line.strip().split(' ')
assert(len(tok) > 0)
deprecated = ''
if tok[0][0] == '!':
assert(len(tok[0]) > 1)
deprecated = '__'
tok[0] = tok[0][1:]
if len(tok) == 1: if len(tok) == 1:
name = tok[0] name = tok[0]
p1 = "NOPRM" p1 = "NOPRM"
@ -97,11 +99,11 @@ for _, line in enumerate(fp):
p1 = "__TOK_ERROR__" p1 = "__TOK_ERROR__"
p2 = "__TOK_ERROR__" p2 = "__TOK_ERROR__"
ls.write("{}\n".format(name)); ls.write("{}{}\n".format(deprecated, name))
hd.write("#ifdef _NEED_ARCH_I\n") hd.write("#ifdef _NEED_ARCH_I\n")
hd.write('{{ "{}", "{}", {}, {}, i_{} }},\n'\ hd.write('{{ "{}{}", "{}{}", {}, {}, i_{} }},\n'\
.format(tok[0], name, p1, p2, tok[0])) .format(deprecated, tok[0], deprecated, name, p1, p2, tok[0]))
hd.write("#else\n") hd.write("#else\n")
hd.write("#define I_{} {}\n".format(name.upper(), count)) hd.write("#define I_{} {}\n".format(name.upper(), count))
hd.write("extern bool i_{}(ctx_t *, acc_t *, acc_t *, ulong *, ulong *);\n" hd.write("extern bool i_{}(ctx_t *, acc_t *, acc_t *, ulong *, ulong *);\n"