mirror of
https://gitlab.os-k.eu/os-k-team/kvisc.git
synced 2023-08-25 14:05:46 +02:00
49 lines
928 B
C
49 lines
928 B
C
|
// The OS/K Team licences this file to you under the MIT license.
|
||
|
// See the LICENCE file in the project root for more information.
|
||
|
|
||
|
#include "arch.h"
|
||
|
|
||
|
ushort prog[] = {
|
||
|
I_ADD, RDX, A_IMM32, 0xAABB, 0xCCDD,
|
||
|
I_MOV, RAX, RDX,
|
||
|
I_MOV, RBX, A_IMM64, 0x7777, 0x6666, 0x5555, 0x4444,
|
||
|
I_SUB, RDX, A_IMM16, 0xCCDD,
|
||
|
I_MOV, RBP, A_IMM16, 0x0010,
|
||
|
I_MUL, A_IMM64, 0xFFFF,0xFFFF,0xFFFF,0xFFFF,
|
||
|
I_ADD, RAX, A_IMM32, 0xAABB, 0xCCDD,
|
||
|
};
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
|