Guide to RISC Processors: For Programmers and Engineers

Chapter 13: Arithmetic Instructions

This chapter describes the arithmetic instructions of the MIPS instruction set in detail. We have introduced some of the basic arithmetic operations such as add and subtract in Chapter 10. Here we provide a thorough discussion of the arithmetic instructions, including the pseudoinstructions supported by the assembler. We then give several examples to illustrate their use in assembly language programs. We conclude the chapter with a summary.

Introduction

The MIPS instruction set supports the four basic arithmetic operations: addition, subtraction, multiplication, and division. We have already introduced the basic add and subtract instructions. These instructions can potentially cause overflow/underflow problems. The MIPS architecture deals with them by generating an exception.

In addition to the add and subtract instructions, two pseudoinstructions are provided for signed integers. One computes the absolute value and the other reverses the sign of a number (i.e., a positive number is converted into a negative number and vice versa).

Multiplication is more complicated than addition or subtraction for these reasons: (i) it produces a result that is double the size of the input operands. For example, multiplying two 32-bit numbers produces a 64-bit result. (ii) We need two separate instructions to operate signed and unsigned numbers. In contrast, the add instruction can be used with both signed and unsigned numbers. We give details on how the MIPS instruction set handles these complications.

The division operation is even more complicated than multiplication for the following reasons: (i) it produces two results: a quotient and a remainder. For example,...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Digital Signal Processors (DSP)
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.