barcode reader in asp.net THE PIC MICROCONTROLLER S ALU in Software

Generator QR Code in Software THE PIC MICROCONTROLLER S ALU

THE PIC MICROCONTROLLER S ALU
QR Code ISO/IEC18004 Decoder In None
Using Barcode Control SDK for Software Control to generate, create, read, scan barcode image in Software applications.
QR Code ISO/IEC18004 Encoder In None
Using Barcode printer for Software Control to generate, create Denso QR Bar Code image in Software applications.
Input A Input B
Scanning QR In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
QR-Code Printer In C#
Using Barcode printer for .NET Control to generate, create QR Code JIS X 0510 image in .NET applications.
Adder
QR Code Creator In .NET
Using Barcode creator for ASP.NET Control to generate, create QR Code image in ASP.NET applications.
QR Code Printer In Visual Studio .NET
Using Barcode drawer for .NET Control to generate, create QR Code ISO/IEC18004 image in VS .NET applications.
Subtractor
Drawing Quick Response Code In Visual Basic .NET
Using Barcode creator for .NET framework Control to generate, create QR Code image in VS .NET applications.
Draw Code128 In None
Using Barcode generation for Software Control to generate, create Code 128 Code Set A image in Software applications.
L-Shift
ANSI/AIM Code 39 Printer In None
Using Barcode generation for Software Control to generate, create Code 3 of 9 image in Software applications.
Draw UPC Code In None
Using Barcode generation for Software Control to generate, create UPC-A image in Software applications.
R-Shift
Barcode Generation In None
Using Barcode creator for Software Control to generate, create barcode image in Software applications.
Data Matrix Generator In None
Using Barcode creator for Software Control to generate, create Data Matrix 2d barcode image in Software applications.
Multiplexor
Make RoyalMail4SCC In None
Using Barcode generator for Software Control to generate, create British Royal Mail 4-State Customer Code image in Software applications.
Code 128 Code Set C Encoder In Objective-C
Using Barcode creation for iPad Control to generate, create Code 128A image in iPad applications.
Result
Encoding European Article Number 13 In Visual Studio .NET
Using Barcode drawer for ASP.NET Control to generate, create EAN13 image in ASP.NET applications.
Code 128A Generator In Java
Using Barcode printer for Android Control to generate, create Code 128 Code Set C image in Android applications.
STATUS
Create Data Matrix 2d Barcode In None
Using Barcode encoder for Font Control to generate, create Data Matrix ECC200 image in Font applications.
Drawing GS1 - 13 In Objective-C
Using Barcode creation for iPhone Control to generate, create EAN13 image in iPhone applications.
Figure 6.7 Multiplexor used to select arithmetic/bitwise operation result to output from the PIC microcontroller processor ALU.
Creating European Article Number 13 In None
Using Barcode generation for Word Control to generate, create European Article Number 13 image in Microsoft Word applications.
ANSI/AIM Code 39 Generation In None
Using Barcode creation for Office Word Control to generate, create Code 39 image in Word applications.
As can be seen in this table, the 12 operations could be reduced to 6 basic operations with the constants 1 and 0xFF provided as extra inputs along with immediate and register data. Note that the basic bitwise operations (AND, OR, XOR, Shift left, and Shift right) do not have equivalencies, but this is not a problem because they are usually simple functions to implement in logic. This is not true for the arithmetic operations. For example, instead of providing a separate subtractor, the ALU s adder
TABLE 6.4 OPERATION
AVAILABLE PIC MICROCONTROLLER ALU OPERATIONS EQUIVALENT OPERATION
Move Addition Subtraction Negation Increment Decrement AND OR XOR Complement Shift left Shift right
AND with 0xFF None Addition to value XORed with 0xFF and incremented XOR with 0xFF and increment Addition with one Addition with 0xFF None None None XOR with 0xFF None None
THE MICROCHIP PIC MCU PROCESSOR ARCHITECTURE
Input A
Input B
Complement Incrementer
Multiplexor
Adder
Result
STATUS
Figure 6.8 Combining operations to provide addition, subtraction, incrementing, and decrementing with a single adder.
could be used with the addition of some simple circuits to provide an addition and subtraction capability, as shown in Fig. 6.8. I have used Subtract as an example here because it is an instruction that you probably will learn to hate as you start working with the PIC microcontroller. The reason for the problems with subtraction is because the result of the operation probably won t make sense to you unless you look at how the operation is carried out and how the hardware is implemented, as shown in Fig. 6.7. I will go through the subtraction instructions in more detail in the next chapter, but to introduce subtraction and help show how the PIC microcontroller s ALU works, I wanted to show how an adder with a few additional circuits could be used to provide addition and subtraction instructions using only an incrementer and a selectable negation circuit. The other instructions in the PIC microcontroller work as you would expect, and optimization of the ALU does not result in any other nonconventional instruction execution. The circuit in Fig. 6.7 could be enhanced further by selecting between 0 (0x00) and the basic ALU Input B selection. The circuit then looks like Fig. 6.9, which can do addition, subtraction, incrementing, and decrementing. Incrementing and decrementing are carried out by selecting the 0 input and then either incrementing it (to add one to the Input A) or decrementing it (adding 0xFF or 1 to Input A). When Microchip engineers designed the PIC microcontroller s ALU, they used tricks such as this to avoid having to add redundant circuitry to the chip. As with many microcontrollers, the PIC microcontroller instruction set has the capability of modifying and testing individual bits in registers. These instructions are not as clever as you may think and are, in fact, implemented with the base hardware I ve described in this section. A bit Set instruction simply ORs a register with a value that has the appropriate bit set. A bit Clear (or Reset) instruction ANDs the contents of a register with a byte that has all the bits set except for the one to be cleared. I m mentioning
THE PIC MICROCONTROLLER S ALU
Input A
Input B
0x00
Multiplexor Complement Incrementer
Multiplexor
Adder
Result
STATUS
Figure 6.9 Adding multiple inputs to the Input B of the ALU adder/subtractor circuit adds the ability to increment and decrement Input A.
this here because it is important to realize that entire registers are read in, modi ed by the AND/OR functions, and then written back to the register. As I will show later in this book, not being aware of the method used in the PIC microcontroller for setting and clearing bits can result in some vexing problems when some applications execute.
THE STATUS REGISTER
The STATUS register is the primary central processing unit (CPU) execution control register used for recording the results of arithmetic and bitwise operations and allowing the use of this data to control the execution of application code. The operation results bit register is common to all computer processors, but the PIC microcontroller is somewhat unique in that it makes the data available to the application code, and it is used directly (not indirectly in some instructions) for program execution control. The STATUS register s organization is different in each of the PIC microcontroller architectures, but they all have the same 3 bits of data after arithmetic and bitwise operations. The 3 bits (or ags) that are set or reset depending on the result of the arithmetic or bitwise operation are the carry, digit carry, and zero bits. These bits are often referred to as the execution status ags (Z, DC, and C). The zero ag (Z) is set when the result of an operation is 0. For example, ANDing 0x5A with 0xA5 is
Copyright © OnBarcode.com . All rights reserved.