EasyManua.ls Logo

Microchip Technology dsPIC30F - Arithmetic Logic Unit (ALU)

Microchip Technology dsPIC30F
738 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
© 2004 Microchip Technology Inc. DS70049C-page 2-17
Section 2. CPU
CPU
2
2.5 Arithmetic Logic Unit (ALU)
The dsPIC30F ALU is 16-bits wide and is capable of addition, subtraction, single bit shifts and
logic operations. Unless otherwise mentioned, arithmetic operations are 2’s complement in
nature. Depending on the operation, the ALU may affect the values of the Carry (C), Zero (Z),
Negative (N), Overflow (OV) and Digit Carry (DC) status bits in the SR register. The C and DC
status bits operate as a Borrow
and Digit Borrow bits, respectively, for subtraction operations.
The ALU can perform 8-bit or 16-bit operations, depending on the mode of the instruction that is
used. Data for the ALU operation can come from the W register array or data memory depending
on the Addressing mode of the instruction. Likewise, output data from the ALU can be written to
the W register array or a data memory location.
Refer to the dsPIC30F Programmer’s Reference Manual (DS70030) for information on the SR
bits affected by each instruction, Addressing modes and 8-bit/16-bit Instruction modes.
2.5.1 Byte to Word Conversion
The dsPIC30F has two instructions that are helpful when mixing 8-bit and 16-bit ALU operations.
The sign-extend (SE) instruction takes a byte value in a W register or data memory and creates
a sign-extended word value that is stored in a W register. The zero-extend (ZE) instruction clears
the 8 MSbs of a word value in a W register or data memory and places the result in a destination
W register.
Note 1: Byte operations use the 16-bit ALU and can produce results in excess of 8 bits.
However, to maintain backward compatibility with PICmicro devices, the ALU result
from all byte operations is written back as a byte (i.e., MSByte not modified), and
the SR register is updated based only upon the state of the LSByte of the result.
2: All register instructions performed in Byte mode only affect the LSByte of the W
registers. The MSByte of any W register can be modified by using file register
instructions that access the memory mapped contents of the W registers.

Table of Contents

Other manuals for Microchip Technology dsPIC30F