simulavr  1.1.0
decoder.cpp File Reference
#include "decoder.h"
#include "hwstack.h"
#include "flash.h"
#include "hwwado.h"
#include "hwsreg.h"
#include "avrerror.h"
#include "ioregs.h"

Go to the source code of this file.

Enumerations

enum  decoder_operand_masks {
  mask_Rd_2 = 0x0030, mask_Rd_3 = 0x0070, mask_Rd_4 = 0x00f0, mask_Rd_5 = 0x01f0,
  mask_Rr_3 = 0x0007, mask_Rr_4 = 0x000f, mask_Rr_5 = 0x020f, mask_K_8 = 0x0F0F,
  mask_K_6 = 0x00CF, mask_k_7 = 0x03F8, mask_k_12 = 0x0FFF, mask_k_22 = 0x01F1,
  mask_reg_bit = 0x0007, mask_sreg_bit = 0x0070, mask_q_displ = 0x2C07, mask_A_5 = 0x00F8,
  mask_A_6 = 0x060F
}
 

Functions

static int n_bit_unsigned_to_signed (unsigned int val, int n)
 
static int get_add_carry (byte res, byte rd, byte rr, int b)
 
static int get_add_overflow (byte res, byte rd, byte rr)
 
static int get_sub_carry (byte res, byte rd, byte rr, int b)
 
static int get_sub_overflow (byte res, byte rd, byte rr)
 
static int get_compare_carry (byte res, byte rd, byte rr, int b)
 
static int get_compare_overflow (byte res, byte rd, byte rr)
 
static int get_rd_2 (word opcode)
 
static int get_rd_3 (word opcode)
 
static int get_rd_4 (word opcode)
 
static int get_rd_5 (word opcode)
 
static int get_rr_3 (word opcode)
 
static int get_rr_4 (word opcode)
 
static int get_rr_5 (word opcode)
 
static byte get_K_8 (word opcode)
 
static byte get_K_6 (word opcode)
 
static int get_k_7 (word opcode)
 
static int get_k_12 (word opcode)
 
static int get_k_22 (word opcode)
 
static int get_reg_bit (word opcode)
 
static int get_sreg_bit (word opcode)
 
static int get_q (word opcode)
 
static int get_A_5 (word opcode)
 
static int get_A_6 (word opcode)
 
DecodedInstructionlookup_opcode (word opcode, AvrDevice *core)
 Translates an opcode to a instance of DecodedInstruction. More...
 

Enumeration Type Documentation

◆ decoder_operand_masks

Enumerator
mask_Rd_2 

2 bit register id ( R24, R26, R28, R30 )

mask_Rd_3 

3 bit register id ( R16 - R23 )

mask_Rd_4 

4 bit register id ( R16 - R31 )

mask_Rd_5 

5 bit register id ( R00 - R31 )

mask_Rr_3 

3 bit register id ( R16 - R23 )

mask_Rr_4 

4 bit register id ( R16 - R31 )

mask_Rr_5 

5 bit register id ( R00 - R31 )

mask_K_8 

for 8 bit constant

mask_K_6 

for 6 bit constant

mask_k_7 

for 7 bit relative address

mask_k_12 

for 12 bit relative address

mask_k_22 

for 22 bit absolute address

mask_reg_bit 

register bit select

mask_sreg_bit 

status register bit select

mask_q_displ 

address displacement (q)

mask_A_5 

5 bit register id ( R00 - R31 )

mask_A_6 

6 bit IO port id

Definition at line 43 of file decoder.cpp.

Function Documentation

◆ get_A_5()

static int get_A_5 ( word  opcode)
static

Definition at line 1935 of file decoder.cpp.

References mask_A_5.

◆ get_A_6()

static int get_A_6 ( word  opcode)
static

Definition at line 1940 of file decoder.cpp.

References mask_A_6.

◆ get_add_carry()

static int get_add_carry ( byte  res,
byte  rd,
byte  rr,
int  b 
)
static

Definition at line 1781 of file decoder.cpp.

Referenced by avr_op_ADC::operator()(), and avr_op_ADD::operator()().

◆ get_add_overflow()

static int get_add_overflow ( byte  res,
byte  rd,
byte  rr 
)
static

Definition at line 1789 of file decoder.cpp.

Referenced by avr_op_ADC::operator()(), and avr_op_ADD::operator()().

◆ get_compare_carry()

static int get_compare_carry ( byte  res,
byte  rd,
byte  rr,
int  b 
)
static

◆ get_compare_overflow()

static int get_compare_overflow ( byte  res,
byte  rd,
byte  rr 
)
static

◆ get_k_12()

static int get_k_12 ( word  opcode)
static

Definition at line 1901 of file decoder.cpp.

References mask_k_12.

◆ get_k_22()

static int get_k_22 ( word  opcode)
static

Definition at line 1906 of file decoder.cpp.

References mask_k_22.

◆ get_K_6()

static byte get_K_6 ( word  opcode)
static

Definition at line 1890 of file decoder.cpp.

References mask_K_6.

◆ get_k_7()

static int get_k_7 ( word  opcode)
static

Definition at line 1896 of file decoder.cpp.

References mask_k_7.

◆ get_K_8()

static byte get_K_8 ( word  opcode)
static

Definition at line 1884 of file decoder.cpp.

References mask_K_8.

◆ get_q()

static int get_q ( word  opcode)
static

Definition at line 1927 of file decoder.cpp.

References mask_q_displ.

◆ get_rd_2()

static int get_rd_2 ( word  opcode)
static

Definition at line 1844 of file decoder.cpp.

References mask_Rd_2.

◆ get_rd_3()

static int get_rd_3 ( word  opcode)
static

Definition at line 1850 of file decoder.cpp.

References mask_Rd_3.

◆ get_rd_4()

static int get_rd_4 ( word  opcode)
static

Definition at line 1856 of file decoder.cpp.

References mask_Rd_4.

◆ get_rd_5()

static int get_rd_5 ( word  opcode)
static

Definition at line 1862 of file decoder.cpp.

References mask_Rd_5.

◆ get_reg_bit()

static int get_reg_bit ( word  opcode)
static

Definition at line 1917 of file decoder.cpp.

References mask_reg_bit.

◆ get_rr_3()

static int get_rr_3 ( word  opcode)
static

Definition at line 1868 of file decoder.cpp.

References mask_Rr_3.

◆ get_rr_4()

static int get_rr_4 ( word  opcode)
static

Definition at line 1873 of file decoder.cpp.

References mask_Rr_4.

◆ get_rr_5()

static int get_rr_5 ( word  opcode)
static

Definition at line 1878 of file decoder.cpp.

References mask_Rr_5.

◆ get_sreg_bit()

static int get_sreg_bit ( word  opcode)
static

Definition at line 1922 of file decoder.cpp.

References mask_sreg_bit.

◆ get_sub_carry()

static int get_sub_carry ( byte  res,
byte  rd,
byte  rr,
int  b 
)
static

◆ get_sub_overflow()

static int get_sub_overflow ( byte  res,
byte  rd,
byte  rr 
)
static

◆ lookup_opcode()

◆ n_bit_unsigned_to_signed()

static int n_bit_unsigned_to_signed ( unsigned int  val,
int  n 
)
static

Definition at line 1830 of file decoder.cpp.