Skip to content

Commit

Permalink
Finished CFG-29-fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaver authored and tomasanchez committed Jun 2, 2022
1 parent d727817 commit e3e6e05
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion cpu/src/module/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,22 @@ interrupt_server_routine(void *sv_data);
*/
static int
on_run_server(servidor_t *server, const char *server_name);

/**
* @brief
*
* @param cpu
*/
void cycle(cpu_t* cpu);

/**
* @brief
*
* @return instruction_t
*/
instruction_t* instructionFetch();


// ============================================================================================================
// ***** Public Functions *****
// ============================================================================================================
Expand Down Expand Up @@ -159,7 +175,8 @@ int on_run(cpu_t *cpu)

for (;;)
{
sleep(TIEMPO_ESPERA);
cycle(cpu);

LOG_INFO("[CPU] :=> Sleep...");
}

Expand All @@ -184,6 +201,37 @@ int on_before_exit(cpu_t *cpu)
return exit_code;
}

void cycle(cpu_t* cpu){

instruction_t* instruction;

instruction = instructionFetch(cpu);

//TODO: Decode

//TODO: Fetch Operands

//TODO: Execute NO_OP

//TODO: Execute I/O

//TODO: Execute EXIT


}

instruction_t* instructionFetch(cpu_t *cpu)
{
instruction_t* instruction = list_get(cpu->pcb->instructions,cpu->pcb->pc);

cpu->pcb->pc++;
return instruction;
}

//TODO:
//funcion Decode .....


// ------------------------------------------------------------
// Event Handlers
// ------------------------------------------------------------
Expand Down

0 comments on commit e3e6e05

Please sign in to comment.