emulator/src/toy.h

70 lines
1.4 KiB
C
Raw Permalink Normal View History

2017-08-02 20:10:36 +02:00
#ifndef TOY_H
#define TOY_H
2017-08-14 13:29:24 +02:00
#define CPU_TYPE "Koopman_TOY_CPU"
2017-09-27 16:25:58 +02:00
#define RAM_SIZE 4096
2017-08-02 20:10:36 +02:00
#define CPU_WORD_SIZE 16
extern const uint16_t * const ACCU; //read only access to accu
/**
2017-10-02 01:19:11 +02:00
* print_instructionSet(): prints the cpu instruction set.
* This is a user help function and can be activated via
2017-10-04 16:23:55 +02:00
* the -h parameter.
2017-09-27 16:25:58 +02:00
* Return: none
*/
2017-08-17 20:40:25 +02:00
void print_instructionSet(void);
/**
* print_instructionSet(): prints the cpu architecture.
* This is a user help function and can be activated via
* the -i parameter.
* Return: none
*/
void print_architecture(void);
/**
* print_instruction(): converts a OP-Code into a human word.
* Return: none
*/
void print_instruction(uint8_t opcode);
/**
2017-10-04 16:23:55 +02:00
* initialise_ram(): reads input stream into the toy-ram.
2017-09-27 16:25:58 +02:00
* Return:
* the number of successfully read machine words,
2017-10-02 01:19:11 +02:00
* -1 in case of error.
2017-09-27 16:25:58 +02:00
*/
2017-09-27 16:25:58 +02:00
int initialise_ram(uint16_t *ram, int argc, char **argv );
/**
2017-10-04 16:23:55 +02:00
* get_opcode(): segments machine code as OP-Code.
* Return: 4-bit OP-Code.
*/
2017-08-02 20:10:36 +02:00
uint8_t get_opcode(uint16_t instruction);
/**
2017-10-04 16:23:55 +02:00
* get_data(): gets the addressed data from RAM.
* Return: the 12-bit data address.
*/
uint16_t get_data(uint16_t instruction);
/**
2017-10-02 01:19:11 +02:00
* execute(): executes the toy-CPU instruction.
2017-10-04 16:23:55 +02:00
* This function implements the CPU instruction set;
* use print_instructionSet() for an overview.
2017-10-02 01:19:11 +02:00
* Return: true if there is a jump.
*/
2017-08-09 22:51:27 +02:00
bool execute(uint8_t op_code, int data_addr,uint16_t *ram);
2017-08-02 20:10:36 +02:00
#endif