Microprocessors: From Assembly Language to C Using thePIC18Fxx2

Chapter 7: Advanced Assembly Language: Higher Math

This chapter examines various higher math topics such as multiplication and division operations for unsigned and signed integers, floating-point number representation, saturating arithmetic, BCD arithmetic, and ASCII/binary conversions.

7.1 LEARNING OBJECTIVES

After reading this chapter, you will be able to:

  • Implement signed and unsigned integer multiplication in PIC18 assembly language.

  • Implement signed and unsigned integer division in PIC18 assembly language.

  • Discuss the formatting and storage requirements of single and double precision floating-point numbers.

  • Implement saturating addition and subtraction operations in PIC18 assembly language.

  • Implement BCD addition and subtraction operations in PIC18 assembly language.

  • Implement ASCII-to-binary and binary-to-ASCII for both hex and decimal number formats in PIC18 assembly language.

7.2 MULTIPLICATION

In C, the multiplication operation is written as product = multiplicand * multiplier. For integer multiply, the number of bits required for the product to prevent overflow is the sum of the bits in the multiplicand and multiplier. Typically, the two operands are the same size; so two n-bit operands produce a 2n-bit result. Figure 7.1 shows a paper and pen multiply of two 3-bit operands that produces a 6-bit product. Starting with the rightmost bit of the multiplier, a partial product is formed by multiplying the multiplier bit with the multiplicand, with the rightmost bit of the partial product aligned under the multiplier bit that produced it. Since this is binary multiplication, a "1" in the multiplier produces a partial product that is equal to the multiplier, while a "0" produces a partial product...

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: Arithmetic Logic Units (ALU)
Finish!
Privacy Policy

This is embarrasing...

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