PZ80emu  0.1
Functions
add.c File Reference

Helper functions for addition operations. More...

#include "../config.h"
#include "add.h"
#include "memory.h"
#include "utils.h"
Include dependency graph for add.c:

Functions

static void carry_handler (struct z80 *cpu)
 
static void ___add8_set_carry_flag (uint8_t a, uint8_t b, struct z80 *cpu)
 sets the carry flag based on the provided 8-bit operands More...
 
static void ___add8_set_zero_flag (uint8_t a, uint8_t b, struct z80 *cpu)
 sets the zero flag based on the provided 8-bit operands More...
 
static void ___add8_set_overflow_flag (uint8_t a, uint8_t b, struct z80 *cpu)
 sets the overflow flag based on the provided 8-bit operands More...
 
static void ___add8_set_sign_flag (uint8_t a, uint8_t b, struct z80 *cpu)
 sets the sign flag based on the provided 8-bit operands More...
 
static void ___add8_set_half_carry_flag (uint8_t a, uint8_t b, struct z80 *cpu)
 sets the half carry flag based on the provided 8-bit operands More...
 
static void __add8_set_flags (uint8_t a, uint8_t b, struct z80 *cpu)
 wrapper to set all flags based on the provided addition operands More...
 
void _add_a_reg8 (struct z80 *cpu, uint8_t *reg)
 adds the contents of a user supplied register to A More...
 
void _adc_a_reg8 (struct z80 *cpu, uint8_t *reg)
 adds the contents of a user supplied register and the carry flag to A More...
 
void _add_a_mem (struct z80 *cpu, uint8_t *memory)
 adds the contents of a user supplied register to A More...
 
void _adc_a_mem (struct z80 *cpu, uint8_t *memory)
 adds contents of A to the contents of a memory address with carry More...
 
void _add_reg16_reg16 (word *reg1, word *reg2, struct z80 *cpu)
 adds two 16-bit registers together, storing the values in reg1 More...
 
void _inc8 (uint8_t *n, struct z80 *cpu)
 increments an 8 bit register More...
 

Detailed Description

Helper functions for addition operations.

Author
Peter H. Ezetta
Date
2018-2019

Function Documentation

◆ ___add8_set_carry_flag()

static void ___add8_set_carry_flag ( uint8_t  a,
uint8_t  b,
struct z80 cpu 
)
static

sets the carry flag based on the provided 8-bit operands

Parameters
afirst operand
bsecond operand
cpuz80 cpu object

◆ ___add8_set_half_carry_flag()

static void ___add8_set_half_carry_flag ( uint8_t  a,
uint8_t  b,
struct z80 cpu 
)
static

sets the half carry flag based on the provided 8-bit operands

Parameters
afirst operand
bsecond operand
cpuz80 cpu object

The H flag is set when there is a carry from bit 3 to bit 4.

◆ ___add8_set_overflow_flag()

static void ___add8_set_overflow_flag ( uint8_t  a,
uint8_t  b,
struct z80 cpu 
)
static

sets the overflow flag based on the provided 8-bit operands

Parameters
afirst operand
bsecond operand
cpuz80 cpu object

For addition operations, the P/V flag is used for overflow. It is set when the 2's Complement result of the operation will not fit in the register.

◆ ___add8_set_sign_flag()

static void ___add8_set_sign_flag ( uint8_t  a,
uint8_t  b,
struct z80 cpu 
)
static

sets the sign flag based on the provided 8-bit operands

Parameters
afirst operand
bsecond operand
cpuz80 cpu object

The S flag is a copy of bit 7 of the result of the operation.

◆ ___add8_set_zero_flag()

static void ___add8_set_zero_flag ( uint8_t  a,
uint8_t  b,
struct z80 cpu 
)
static

sets the zero flag based on the provided 8-bit operands

Parameters
afirst operand
bsecond operand
cpuz80 cpu object

◆ __add8_set_flags()

static void __add8_set_flags ( uint8_t  a,
uint8_t  b,
struct z80 cpu 
)
static

wrapper to set all flags based on the provided addition operands

Parameters
afirst operand
bsecond operand
cpuz80 cpu object
Note
INC doesn't effect C. Do not use this with _inc8() et al.
Here is the call graph for this function:

◆ _adc_a_mem()

void _adc_a_mem ( struct z80 cpu,
uint8_t *  memory 
)

adds contents of A to the contents of a memory address with carry

Parameters
cpuz80 cpu object
memorymemory location to add to A

◆ _adc_a_reg8()

void _adc_a_reg8 ( struct z80 cpu,
uint8_t *  reg 
)

adds the contents of a user supplied register and the carry flag to A

Parameters
cpuz80 cpu object
regregister to add to A

◆ _add_a_mem()

void _add_a_mem ( struct z80 cpu,
uint8_t *  memory 
)

adds the contents of a user supplied register to A

Parameters
cpuz80 cpu object
memorypointer to system memory
Here is the call graph for this function:

◆ _add_a_reg8()

void _add_a_reg8 ( struct z80 cpu,
uint8_t *  reg 
)

adds the contents of a user supplied register to A

Parameters
cpuz80 cpu object
regregister to add to A
Here is the call graph for this function:

◆ _add_reg16_reg16()

void _add_reg16_reg16 ( word reg1,
word reg2,
struct z80 cpu 
)

adds two 16-bit registers together, storing the values in reg1

Parameters
reg1the first register for the add operation
reg2the second register for the add operation
cpuz80 cpu object

◆ _inc8()

void _inc8 ( uint8_t *  n,
struct z80 cpu 
)

increments an 8 bit register

Parameters
npointer to register to increment
cpuz80 cpu object
Here is the call graph for this function:
MD5Context
Definition: config.h:55