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 12:17:31 +02:00
parent c2e412fb7f
commit ed03945762
No known key found for this signature in database
GPG Key ID: DDF8325C95299A62
7 changed files with 26 additions and 56 deletions

View File

@ -9,6 +9,8 @@ import subprocess
from array import array
from tempfile import TemporaryFile
WANT_DISASM = False
if len(sys.argv) != 4:
print("Usage: {} (output file) (memory entry point) (source file)"
.format(sys.argv[0]))
@ -679,8 +681,10 @@ special_syms = {
def gentext():
instrs.seek(0)
print(instrs.read())
instrs.seek(0)
if WANT_DISASM:
int(instrs.read())
instrs.seek(0)
text_start = 0x100000
data_start = text_start + ptext

View File

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

View File

@ -5,7 +5,8 @@
; Main function
;
main:
jmp ramdev_test
call movzx_test
ret
ramdev_test:
call DevGetMemOff

View File

@ -314,9 +314,6 @@ cmpxchg rm rim
# PUSH(RIP)
# JMP(RIP)
#
# Throws:
# See PUSH and JMP
#
call rim
#
@ -324,9 +321,6 @@ call rim
#
# POP(RIP)
#
# Throws:
# See POP
#
ret
#
@ -336,10 +330,6 @@ ret
# RBP = RSP
# RSP = RSP - $1
#
# Throws:
# See PUSH
#
enter
enter i
#

View File

@ -73,10 +73,10 @@ bool i_##name(ctx_t *ctx, acc_t *p1, acc_t *p2, ulong *r1, ulong *r2) \
} \
} while (0)
#define CHK_STACK() \
if (rsp % 8 > 0 || rbp % 8 > 0) { \
#define CHK_STACK() /* \
if (__builtin_expect((rsp % 8 != 0), 0) { \
_except(ctx, E_STA, "Misaligned stack REGS"); \
}
}*/
//----------------------------------------------------------------------------//

View File

@ -9,68 +9,46 @@
IMPL_START_1(push)
{
CHK_STACK();
PUSH(v1);
rsp -= 8;
writemem(ctx, v1, rsp, 8);
}
IMPL_END;
IMPL_START_1(pop)
{
CHK_STACK();
POP(v1);
v1 = readmem(ctx, rsp, 8);
rsp += 8;
}
IMPL_OUT;
IMPL_START_1(call)
{
CHK_STACK();
PUSH(rip);
rsp -= 8;
writemem(ctx, rip, rsp, 8);
JUMP(v1);
}
IMPL_END;
IMPL_START_0(ret)
{
CHK_STACK();
POP(rip);
rip = readmem(ctx, rsp, 8);
rsp += 8;
}
IMPL_END;
IMPL_START_0(enter)
{
CHK_STACK();
PUSH(rbp);
rbp = rsp;
if (p1) {
rsp -= p1->val * 8;
}
writemem(ctx, rbp, rsp - 8, 8);
rbp = rsp - 8;
rsp -= (p1->val + 1) * 8;
}
IMPL_END;
IMPL_START_0(leave)
{
rsp = rbp;
POP(rbp);
}
IMPL_END;
IMPL_START_0(pushf)
{
CHK_STACK();
PUSH(flg);
}
IMPL_END;
IMPL_START_0(popf)
{
CHK_STACK();
// XXX
CHK_SUPERV();
POP(flg);
rsp = rbp + 8;
rbp = readmem(ctx, rbp, 8);
}
IMPL_END;

View File

@ -99,7 +99,7 @@ void dumpregs(ctx_t *ctx)
assert(inv == 0);
DUMPREGS(RAX, RSI);
DUMPREGS(RAX, RDI);
DUMPREGS(AX0, AX3);
DUMPREGS(LX0, LX3);