circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

February 2005, Issue 175

A Look at the M16C Lineup


by Jeff Bachiochi

INSTRUCTION SET

The instruction set is comprised of 91 instructions (see Table 2). Most instructions handle data transfer, math, and bit manipulations. Additional instructions redirect execution flow and support special-purpose functions.

With the immediate addressing modes the actual data to be operated on is in the instruction. In MOV.B #0xFF,P0, the immediate data #0xFF is moved to the port P0 register. When Register Direct mode is used, the data source/destination is a register. If the R0L register has the 0xFF value in it when the MOV.B R0L,P0 instruction is used, this value is taken from R0L and moved to the port P0 register.

Absolute Addressing mode is similar to Direct mode; however, instead of data referring to a named register, it refers to an absolute address. The MOV.W 0XFFFE,R0 instruction moves a word of data from the address 0xFFFE to the R0 register. When a register holds the address of the data instead of the actual data itself, it’s called address register indirect, as in the MOV.W (A0),TCR0 instruction. This instruction moves a word from the address pointed to by the value in A0 to the DMA0 transfer counter.

Relative Addressing mode adds an unsigned offset to a value in a register. The MOV,W 0x100:16(SB),TCR0, instruction adds 0x100 to the value in the static base register and places it in the DMA0 transfer counter. A second Relative Addressing mode adds a signed offset to a value in a register. In this case, MOV,W 0xF100:16(FB),TCR0, is the signed value (negative) added to the value in the frame base register and placed in the DMA0 transfer counter. If any relative calculation overflows or underflows 16 bits, its value is truncated to 16 bits. However, there are 20- and 32-bit operations as well. Also, many of the addressing schemes can be used with bit manipulation.