decoder.c File Reference

Module for handling opcode decoding. More...

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

int avr_op_UNKNOWN (AvrCore *core, uint16_t opcode, unsigned int arg1, unsigned int arg2)
void decode_init_lookup_table (void)
opcode_info * decode_opcode (uint16_t opcode)

Variables

opcode_info * global_opcode_lookup_table


Detailed Description

Module for handling opcode decoding.

The heart of the instruction decoder is the decode_opcode() function.

The decode_opcode() function examines the given opcode to determine which instruction applies and returns a pointer to a function to handler performing the instruction's operation. If the given opcode does not map to an instruction handler, NULL is returned.

Nearly every instruction in Atmel's Instruction Set Data Sheet will have a handler function defined. Each handler will perform all the operations described in the data sheet for a given instruction. A few instructions have synonyms. For example, CBR is a synonym for ANDI.

This should all be fairly straight forward.

Definition in file decoder.c.


Enumeration Type Documentation

enum decoder_operand_masks

Masks to help extracting information from opcodes.

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 77 of file decoder.c.


Function Documentation

void decode_init_lookup_table ( void   ) 

Initialize the decoder lookup table.

This is automatically called by avr_core_construct().

It is safe to call this function many times, since if will only create the table the first time it is called.

Definition at line 3869 of file decoder.c.

References avr_message, avr_new0, and global_opcode_lookup_table.

struct opcode_info* decode_opcode ( uint16_t  opcode  )  [read]

Decode an opcode into the opcode handler function.

Generates a warning and returns NULL if opcode is invalid.

Returns a pointer to the function to handle the opcode.


Automatically generated by Doxygen 1.5.2 on 3 Dec 2007.