1 / 53

Comprehensive Guide to 68HC12 Arithmetic Operations: Addition, Subtraction, and More

Explore the fundamentals of arithmetic operations on the 68HC12 microcontroller. This chapter covers essential topics such as addition, subtraction, multiplication, and division, along with shift and rotate instructions. Learn practical coding examples for basic operations like incrementing and decrementing, and understand how double numbers are handled in the 68HC12. Delve into the complexities of multiplication and division with various methods, including symmetric division and the use of MOD. Enhance your programming skills and optimize performance with these crucial arithmetic techniques.

obert
Télécharger la présentation

Comprehensive Guide to 68HC12 Arithmetic Operations: Addition, Subtraction, and More

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. 68HC12 Arithmetic Chapter 3

  2. 68HC12 Arithmetic • Addition and Subtraction • Double Numbers • Multiplication • Division • Shift and Rotate Instructions

  3. Addition and Subtraction

  4. 68HC12 code for 1+, 2+ ; 1+ ( n -- n+1 ) ONEP LDD 0,X ADDD #1 STD 0,X RTS ; 2+ ( n -- n+2 ) TWOP LDD 0,X ADDD #2 STD 0,X RTS

  5. 68HC12 code for 1-, 2- ; 1- ( n -- n-1 ) ONEP LDD 0,X SUBD #1 STD 0,X RTS ; 2- ( n -- n-2 ) TWOP LDD 0,X SUBD #2 STD 0,X RTS

  6. 68HC12 Arithmetic • Addition and Subtraction • Double Numbers • Multiplication • Division • Shift and Rotate Instructions

  7. Double Numbers

  8. Adding Double Numbers

  9. Subtracting Double Numbers

  10. 68HC12 Arithmetic • Addition and Subtraction • Double Numbers • Multiplication • Division • Shift and Rotate Instructions

  11. Multiplication

  12. Multiplication

  13. Multiplication

  14. 68HC11: A, B, C, D are 8 bits 16 x 16 => 32-bit product 68HC12: A, B, C, D could be 16 bits 32 x 32 => 64-bit product

  15. Multiplication - DUM*

  16. WHYP Multiplication Examples

  17. 68HC12 Arithmetic • Addition and Subtraction • Double Numbers • Multiplication • Division • Shift and Rotate Instructions

  18. Division

  19. WHYP uses symetric (not floored) division

  20. Examples of using / and MOD

  21. Examples of using UM/MOD

  22. MU/MOD

  23. Examples of using MU/MOD

  24. M/MOD

  25. Examples of using M/MOD

  26. */

  27. Examples of using */

  28. IDIV

  29. U/

  30. Examples of using IDIV and U/

  31. FDIV

  32. Examples of using FDIV

  33. 68HC11 version of UM/MOD

  34. 68HC12 Arithmetic • Addition and Subtraction • Double Numbers • Multiplication • Division • Shift and Rotate Instructions

  35. C Bit 7 6 5 4 3 2 1 0 1 1 0 1 0 0 1 0 1 Logic Shift LeftLSL, LSLA, LSLB 0 C Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 1 1 0 1 0 0 1 0 1 0 1 0 1 0 0 1 0 1 A B LSLD

  36. Logic Shift RightLSR, LSRA, LSRB C Bit 7 6 5 4 3 2 1 0 0 1 0 1 0 0 1 0 1 1 C Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 0 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 A B LSRD

  37. Arithmetic Shift RightASR, ASRA, ASRB C 1 0 1 0 0 1 0 1 1

  38. Rotate LeftROL, ROLA, ROLB C Bit 7 6 5 4 3 2 1 0 1 1 0 1 0 0 1 0 1

  39. Rotate RightROR, RORA, RORB C Bit 7 6 5 4 3 2 1 0 1 0 1 0 0 1 0 1 1

  40. 2*, 2/, and U2/

  41. LSHIFT and RSHIFT

More Related