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...
Products & Services
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...