1 / 10

ECT 357

ECT 357. Ch 14 Multiplication/Division/Floating-Point/Math Subroutines. Today’s Quote: The cure of crime is not in the electric chair, but in the high chair. Train up a child in the way he should go: and when he is old, he will not depart from it. Proverbs 22:6.

arnav
Télécharger la présentation

ECT 357

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ECT 357 Ch 14 Multiplication/Division/Floating-Point/Math Subroutines

  2. Today’s Quote: The cure of crime is not in the electric chair, but in the high chair. Train up a child in the way he should go: and when he is old, he will not depart from it. Proverbs 22:6

  3. Multiplication Overview An 8 x 8 hardware multiplier is included in the ALU of the PIC18FXX2 devices. By making the multiply a hardware operation, it completes in a single instruction cycle. This is an unsigned multiply that gives a 16-bit result. The result is stored into the 16-bit product register pair (PRODH:PRODL). The multiplier does not affect any flags in the STATUS register.

  4. Multiplication Overview Making the 8 x 8 multiplier execute in a single cycle gives the following advantages: • Higher computational throughput • Reduces code size requirements for multiply algorithms The performance increase allows the device to be used in applications previously reserved for Digital Signal Processors.

  5. Unsigned Multiply • 2 multiplication instructions MOVF ARG1, W ;memory with wreg MULWF ARG2 MOVF ARG1, W ;literal with wreg MULLW 5 Result placed in PRODH:PRODL

  6. Signed vs. Unsigned Numbers • Invert all bits and add 1 to convert between signed and unsigned.

  7. Signed Multiply • To account for the sign bits of the arguments, each argument’s Most Significant bit (MSb) is tested and the appropriate subtractions are done. • MOVF ARG1, W • MULWF ARG2 ; ARG1 * ARG2 -> PRODH:PRODL • BTFSC ARG2, SB ; Test Sign Bit • SUBWF PRODH, F ; PRODH = PRODH - ARG1 • MOVF ARG2, W • BTFSC ARG1, SB ; Test Sign Bit • SUBWF PRODH, F ; PRODH = PRODH - ARG2

  8. Division Overview • No division instruction • Look up tables (Div/Log) • Multiplication/Division pairs

  9. Math Subroutines • Multiplication subroutines from 8x8 to 32x32 signed and unsigned. • Division subroutines from 8x8 to 32x32 signed and unsigned • Floating point subroutines for: • Conversion • Multiplication • Division • Subtraction • Addition

  10. Subroutine Implementation • #include <C:\MATH18\MATHVARS.inc> • #include <C:\MATH18\FXM1616U.inc> • #include <C:\MATH18\FXD3208U.inc> • #include <C:\MATH18\FPSUBS.inc>

More Related