Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. ;throttle_multiply.asm
  2. ;
  3. ;********************************************************************************
  4. ;* mpy8u                                                                         *
  5. ;* Second Level Subroutine                                                       *
  6. ;*                                                                               *
  7. ;* Program from Atmel file avr200.asm                                            *
  8. ;*                                                                               *
  9. ;* Since the 25kHz pwm cycle is 64 clock cycles long, this subroutine            *
  10. ;* requires just under 1 25kHz clock cycles.                                     *
  11. ;*                                                                               *
  12. ;* A single line was added which adds 3 to Cycle_count                           *
  13. ;*                                                                               *
  14. ;* Inputs:  HILOCAL1 and B_TEMPLOCAL                                             *
  15. ;*                                                                               *
  16. ;* Returns: HILOCAL1 x B_TEMPLOCAL = B_TEMPLOCAL1:B_TEMPLOCAL                    *
  17. ;*                                                                               *
  18. ;* Changed: B_TEMPLOCAL2                                                         *
  19. ;*                                                                               *
  20. ;* Calls:   Not allowed                                                          *  
  21. ;********************************************************************************
  22.  
  23.    HILOCAL1       mc8u                 ; multiplicand
  24.    B_TEMPLOCAL    mp8u                 ; multiplier
  25.    B_TEMPLOCAL    m8uL                 ; result Low byte
  26.    B_TEMPLOCAL1   m8uH                 ; result High byte
  27.    B_TEMPLOCAL2   mcnt8u               ; loop counter
  28.  
  29.  
  30. ;<ATMEL ROUTINE>
  31. ;***************************************************************************
  32. ;*
  33. ;* "mpy8u" - 8x8 Bit Unsigned Multiplication
  34. ;*
  35. ;* This subroutine multiplies the two register variables mp8u and mc8u.
  36. ;* The result is placed in registers m8uH, m8uL
  37. ;*  
  38. ;* Number of words   :9 + return
  39. ;* Number of cycles  :58 + return
  40. ;* Low registers used   :None
  41. ;* High registers used  :4 (mp8u,mc8u/m8uL,m8uH,mcnt8u)  
  42. ;*
  43. ;* Note: Result Low byte and the multiplier share the same register.
  44. ;* This causes the multiplier to be overwritten by the result.
  45. ;*
  46. ;***************************************************************************
  47.  
  48. ;***** Subroutine Register Variables
  49.  
  50. ;.def mc8u  =r16     ;multiplicand
  51. ;.def mp8u  =r17     ;multiplier
  52. ;.def m8uL  =r17     ;result Low byte
  53. ;.def m8uH  =r18     ;result High byte
  54. ;.def mcnt8u   =r19     ;loop counter
  55.  
  56. ;***** Code
  57.  
  58.  
  59. mpy8u:  
  60.    clr   m8uH                          ;clear result High byte
  61.    ldi   mcnt8u,8                      ;init loop counter
  62.    lsr   mp8u                          ;rotate multiplier
  63.    
  64. m8u_1:
  65.    brcc  m8u_2                         ;carry set
  66.    add   m8uH,mc8u                     ;add multiplicand to result High byte
  67. m8u_2:
  68.    ror   m8uH                          ;rotate right result High byte
  69.    ror   m8uL                          ;rotate right result L byte and multiplier
  70.    dec   mcnt8u                        ;decrement loop counter
  71.    brne  m8u_1                         ;if not done, loop more
  72.    ret
  73.  
  74. ;<END ATMEL ROUTINE>
  75.