From Guide to RISC Processors: For Programmers and Engineers

This chapter looks at the logical, shift and rotate instructions provided by MIPS. The MIPS instruction set provides four logical instructions: and, or, xor, and nor. There is no not instruction. This operation can be synthesized from the nor operation. We have introduced some of these instructions in Chapter 10. The logical instructions are useful to implement high-level language logical expressions. In addition, they can be used for bit manipulation. The shift and rotate instructions are useful in bit shift operations. We give several examples to illustrate the use of these instructions. We end the chapter with a summary.

Introduction

As we have seen in the last chapter, high-level languages provide several conditional and loop constructs. These constructs require Boolean or logical expressions to specify conditions. In principle, only a single bit is needed to represent the Boolean data. However, such a representation, although compact, is not convenient, as testing a variable involves isolating the corresponding bit.

Most high-level languages use a byte to represent the Boolean data. If the byte is zero, it represents false; otherwise, true. Note that any value other than 0 can be used to represent true. In C, which does not provide an explicit Boolean data type, any data variable can be used in a logical expression to represent Boolean data. The rules mentioned above apply.

Assembly language provides several logical instructions, which are useful in implementing logical expressions of high-level languages. For example, C provides...

Copyright Springer Science+Business Media, Inc. 2005 under license agreement with Books24x7

Products & Services
Programmable Logic Controllers (PLC)
Programmable logic controllers (PLC) are the control hubs for a wide variety of automated systems and processes. They use a wide variety of inputs and outputs and provide network capability.
RAID Products
RAID products include component within a RAID system, such as RAID controllers and RAID disk arrays. RAID is an acronym for redundant array of independent (or inexpensive) disks.
Microprocessor Chips (MPU)
Microprocessor chips (MPU) are silicon devices that serve as the central processing unit (CPU) in computers. They contain thousands of electronic components and use a collection of machine instructions to perform mathematical operations and move data from one memory location to another.
Shift Registers
Shift registers are sequential logic circuits that are used to store and move data. They accept binary inputs from one serial or parallel source and then shift the data through a chain of flip-flops, one bit at time.

Topics of Interest

We can use recursion as an alternative to iteration. Solutions to some problems can be naturally expressed using recursion. We start this chapter with an overview of recursive procedures. Next we give...

Bit manipulation is an important aspect of many high-level languages. This chapter discusses the logical and bit manipulation instructions supported by the assembly language. Assembly language...

Instruction List The supported instructions are listed in Tables 4.2 4.9. The complete details of each instruction are available in the ARM v7-M Architecture Application Level Reference Manual (Ref...

Overview This chapter introduces the basics of the MIPS assembly language. Assembly language statements can either instruct the processor to perform a task, or direct the assembler during the...

This chapter examines additional features of the PIC18Fxx2 instruction set architecture in the context of unsigned 8-bit arithmetic, bitwise logical, and shift operations. These operations are used to...

Product Announcements
Avnet Electronics Marketing / Design
Texas Instruments Analog Automotive and Transportation