expand code documentation.

This commit is contained in:
lux 2017-10-02 01:19:11 +02:00
parent a717499339
commit 21a33681c0
2 changed files with 28 additions and 11 deletions

View File

@ -2,13 +2,30 @@
#define DEBUG_H #define DEBUG_H
/** /**
* get2compl(): interpret the transfer value as tow's complement * get2compl(): interprets the transfer value as tow's complement
* Return: tow's complement value between -32768 and 32767 * Return: tow's complement value between -32768 and 32767
*/ */
int32_t get2compl(uint16_t value); int32_t get2compl(uint16_t value);
/**
* fprintBits(): interprets an integer value as a binary pattern.(little endian)
* if you pass the datatype and the address of an integer,
* the funktion will supply the binary representation.
* (give "stdout" as the last parameter for standard output,
* otherwise hand over a filepointer)
* Return: none
*/
void fprintBits(size_t const size, void const * const ptr, FILE *file_pointer); void fprintBits(size_t const size, void const * const ptr, FILE *file_pointer);
/**
* makeHexDump(): writes the RAM content to a textfile.
* if you pass true to base_2, binary code is written to the textfile,
* otherwise hexcode.
* Return: none
*/
void makeHexDump(bool base_2, uint16_t ram[]); void makeHexDump(bool base_2, uint16_t ram[]);
#endif #endif

View File

@ -9,8 +9,8 @@
extern const uint16_t * const ACCU; //read only access to accu extern const uint16_t * const ACCU; //read only access to accu
/** /**
* print_instructionSet(): print the cpu instruction set * print_instructionSet(): prints the cpu instruction set.
* This is a user help function, can be activated via * This is a user help function and can be activated via
* the -h paramter. * the -h paramter.
* Return: none * Return: none
*/ */
@ -18,33 +18,33 @@ extern const uint16_t * const ACCU; //read only access to accu
void print_instructionSet(void); void print_instructionSet(void);
/** /**
* initialise_ram(): read inputstream into the toy-ram * initialise_ram(): reads inputstream into the toy-ram.
* Return: * Return:
* the number of successfully read machine words, * the number of successfully read machine words,
* -1 in case of error * -1 in case of error.
*/ */
int initialise_ram(uint16_t *ram, int argc, char **argv ); int initialise_ram(uint16_t *ram, int argc, char **argv );
/** /**
* get_opcode(): segments the mashine code in the OP-Code * get_opcode(): segments the mashine code in the OP-Code.
* Return: 4 bit OP-Code * Return: 4 bit OP-Code.
*/ */
uint8_t get_opcode(uint16_t instruction); uint8_t get_opcode(uint16_t instruction);
/** /**
* get_data(): get the addressed data from the RAM * get_data(): gets the addressed data from the RAM.
* Return: the 12 bit data address * Return: the 12 bit data address.
*/ */
uint16_t get_data(uint16_t instruction); uint16_t get_data(uint16_t instruction);
/** /**
* execute(): execute the toy-CPU instruction * execute(): executes the toy-CPU instruction.
* This function implements the CPU instruction set, * This function implements the CPU instruction set,
* use print_instructionSet() for an overview. * use print_instructionSet() for an overview.
* Return: true if there is a jump * Return: true if there is a jump.
*/ */
bool execute(uint8_t op_code, int data_addr,uint16_t *ram); bool execute(uint8_t op_code, int data_addr,uint16_t *ram);