1
0
mirror of https://gitlab.os-k.eu/os-k-team/kvisc.git synced 2023-08-25 14:05:46 +02:00
kvisc/karch/main.c

49 lines
954 B
C
Raw Normal View History

2019-05-15 19:26:40 +02:00
// The OS/K Team licences this file to you under the MIT license.
2019-05-15 21:56:42 +02:00
// See the LICENSE file in the project root for more information.
2019-05-15 19:26:40 +02:00
#include "arch.h"
ushort prog[] = {
2019-05-15 21:47:08 +02:00
I_ADD_R_I, RDX, A_IMM32, 0xAABB, 0xCCDD,
I_MOV_R_R, RAX, RDX,
I_MOV_R_I, RBX, A_IMM64, 0x7777, 0x6666, 0x5555, 0x4444,
I_SUB_R_I, RDX, A_IMM16, 0xCCDD,
I_MOV_R_I, RBP, A_IMM16, 0x0010,
I_MUL_I, A_IMM64, 0xFFFF,0xFFFF,0xFFFF,0xFFFF,
I_ADD_R_I, RAX, A_IMM32, 0xAABB, 0xCCDD,
2019-05-15 19:26:40 +02:00
};
ushort bget(ctx_t *ctx)
{
static int i = 0;
if (i >= sizeof(prog)/sizeof(ushort)) {
_except(ctx, E_ACC, "End of text");
}
return prog[i++];
}
extern reg_t arch_r[NREGS];
extern instr_t arch_i[NINSTRS];
int main(void)
{
static ctx_t main_ctx;
main_ctx.r = arch_r;
main_ctx.i = arch_i;
main_ctx.mp = 0;
main_ctx.mz = 0;
main_ctx.get = bget;
while (1) {
decode(&main_ctx);
}
return 0;
}