8080-Emulator  0.1
An Intel 8080 emulator for Space Invaders
Functions
cpu_8080.c File Reference

This file contains a software abstraction of intel 8080 CPU, enough to run invaders. More...

#include <stdlib.h>
#include <inttypes.h>
#include <stdio.h>
#include "debug.h"
#include "cpu_8080.h"
#include "opcodes_8080.h"
Include dependency graph for cpu_8080.c:

Functions

cpu_stateinit_cpu_8080 (uint16_t pc, uint8_t(*in_cb)(uint8_t), void(*out_cb)(uint8_t, uint8_t))
 Initialize a new cpu_8080 instance structure. Everything is initialized to 0. More...
 
int exec_inst (cpu_state *cpu)
 Executes the instruction pc is pointing to after incrementing it. More...
 
int decompile_inst (cpu_state *cpu, uint16_t *next_inst)
 Recompile mode. More...
 
void io_machine_OUT (UNUSED uint8_t port, UNUSED uint8_t data)
 Default function for IO_WRAP This function would be triggered on an OUT instruction. Usually overriden by the caller during setup. More...
 
uint8_t io_machine_IN (UNUSED uint8_t port)
 Default function for IO_WRAP This function would be triggered on an IN instruction. Usually overriden by the caller during setup. More...
 
void print_state (const cpu_state cpu)
 Print the state of CPU. More...
 

Detailed Description

This file contains a software abstraction of intel 8080 CPU, enough to run invaders.

Author
Pranay Garg (prana.nosp@m.yga@.nosp@m.andre.nosp@m.w.cm.nosp@m.u.edu)
Version
0.1
Date
2020-12-20

Function Documentation

◆ decompile_inst()

int decompile_inst ( cpu_state cpu,
uint16_t *  next_inst 
)

Recompile mode.

Parameters
cpu
next_inst
Returns
int

◆ exec_inst()

int exec_inst ( cpu_state cpu)

Executes the instruction pc is pointing to after incrementing it.

Parameters
cpu
Returns
int

◆ init_cpu_8080()

cpu_state* init_cpu_8080 ( uint16_t  pc,
uint8_t(*)(uint8_t)  in_cb,
void(*)(uint8_t, uint8_t)  out_cb 
)

Initialize a new cpu_8080 instance structure. Everything is initialized to 0.

Parameters
pcProgram counter initialization
in_cb
out_cb
Returns
cpu_state* Pointer to the Malloced CPU state.
Note
  • the user is responsible for freeing the memory (for the CPU) once it's done
  • expects base to be initialized by the user to a 64KB aligned memory
Returns
cpu_state*

◆ io_machine_IN()

uint8_t io_machine_IN ( UNUSED uint8_t  port)

Default function for IO_WRAP This function would be triggered on an IN instruction. Usually overriden by the caller during setup.

Parameters
port
Returns
uint8_t

◆ io_machine_OUT()

void io_machine_OUT ( UNUSED uint8_t  port,
UNUSED uint8_t  data 
)

Default function for IO_WRAP This function would be triggered on an OUT instruction. Usually overriden by the caller during setup.

Parameters
port
data

◆ print_state()

void print_state ( const cpu_state  cpu)

Print the state of CPU.

Parameters
cpu