Skip to content
Snippets Groups Projects
Commit aceca5c0 authored by ryuzakighost's avatar ryuzakighost
Browse files

merge

parents 62599f95 85d081e5
No related branches found
No related tags found
No related merge requests found
...@@ -58,7 +58,7 @@ static void machine_init(void){ ...@@ -58,7 +58,7 @@ static void machine_init(void){
memory = malloc(sizeof(int32_t)*MEMORY_SIZE); memory = malloc(sizeof(int32_t)*MEMORY_SIZE);
regs = malloc(sizeof(int32_t)*NUM_REGS); regs = malloc(sizeof(int32_t)*NUM_REGS);
memset(memory,0,sizeof(int32_t)*MEMORY_SIZE); memset(memory,0,sizeof(int32_t)*MEMORY_SIZE);
memset(regs,0,sizeof(int32_t)*NUM_REGS); memset(regs,0,sizeof(int32_t)*(NUM_REGS-1));
count = 0; count = 0;
} }
......
...@@ -57,8 +57,8 @@ unsigned int count = 0; /* counts number of instructions executed so far */ ...@@ -57,8 +57,8 @@ unsigned int count = 0; /* counts number of instructions executed so far */
static void machine_init(void){ static void machine_init(void){
memory = malloc(sizeof(int32_t)*MEMORY_SIZE); memory = malloc(sizeof(int32_t)*MEMORY_SIZE);
regs = malloc(sizeof(int32_t)*NUM_REGS); regs = malloc(sizeof(int32_t)*NUM_REGS);
memset(memory,0,sizeof(int32_t)*MEMORY_SIZE); //memset(memory,0,sizeof(int32_t)*MEMORY_SIZE);
memset(regs,0,sizeof(int32_t)*NUM_REGS); // memset(regs,0,sizeof(int32_t)*NUM_REGS);
count = 0; count = 0;
} }
...@@ -226,7 +226,7 @@ int execute(const unsigned int progLength, const int cycles, int32_t * res){ ...@@ -226,7 +226,7 @@ int execute(const unsigned int progLength, const int cycles, int32_t * res){
unsigned int cyclesExecuted = 0; unsigned int cyclesExecuted = 0;
while(cycles > 0 ? cyclesExecuted < (unsigned int)cycles : true){ while(cycles > 0 ? cyclesExecuted < (unsigned int)cycles : true){
cyclesExecuted++; cyclesExecuted++;
if (pc < 0 || pc >= (int)progLength){ if (pc >= (int)progLength){
/* will cause an error but that is not a bug and /* will cause an error but that is not a bug and
* and indeed is what the VM is supposed to do if the pc becomes * and indeed is what the VM is supposed to do if the pc becomes
* negative, since in this case the program's execution finishes * negative, since in this case the program's execution finishes
......
pw.println("RET R31");
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment