From 2904c1c211c7584aa8b8d4649cd30fe90a584b84 Mon Sep 17 00:00:00 2001 From: Morten Delenk Date: Sun, 5 Jun 2016 12:51:33 +0000 Subject: [PATCH] Added storing and loading 16 and 32 bits of RAM --- prototypes/supervm/main.c | 2 +- prototypes/supervm/vm.c | 25 ++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/prototypes/supervm/main.c b/prototypes/supervm/main.c index c078047..de06cd7 100644 --- a/prototypes/supervm/main.c +++ b/prototypes/supervm/main.c @@ -175,4 +175,4 @@ int main(int argc, const char **argv) dump_memory(p); return 0; -} \ No newline at end of file +} diff --git a/prototypes/supervm/vm.c b/prototypes/supervm/vm.c index 92f8c30..920a106 100644 --- a/prototypes/supervm/vm.c +++ b/prototypes/supervm/vm.c @@ -9,12 +9,31 @@ static void cmd_copy(CommandInfo *info) static void cmd_load(Process *p, CommandInfo *info) { - info->output = vm_read_byte(p, info->input0); + info->output = 0; + switch(info->additional) { + case 2: + info->output|=(uint32_t)(vm_read_byte(p, info->input0+3))<<24; + info->output|=(uint32_t)(vm_read_byte(p, info->input0+2))<<16; + case 1: + info->output|=(uint32_t)(vm_read_byte(p, info->input0+1))<< 8; + case 0: + info->output|=(uint32_t)(vm_read_byte(p, info->input0+0))<< 0; + break; + } } static void cmd_store(Process *p, CommandInfo *info) { - vm_write_byte(p, info->input0, info->input1); + switch(info->additional) { + case 2: + vm_write_byte(p, info->input0+3, info->input1>>24); + vm_write_byte(p, info->input0+2, info->input1>>16); + case 1: + vm_write_byte(p, info->input0+1, info->input1>>8); + case 0: + vm_write_byte(p, info->input0, info->input1); + break; + } info->output = info->input1; } @@ -239,4 +258,4 @@ void vm_write_byte(Process *process, uint32_t address, uint8_t value) vm_assert(page < process->mmap.length, "Out of memory."); process->mmap.pages[page][index] = value; -} \ No newline at end of file +}