picbasicpro with rotation


Closed Thread
Results 1 to 3 of 3
  1. #1
    cesurcelik's Avatar
    cesurcelik Guest

    Default picbasicpro with rotation

    hi all.
    i want to rotate 48 bits data with picbasic pro,but i don't know how to do that.
    if someone helped me about it ,i'd appreciate it.
    thank you in advance.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    You might want to run this through the MPLAB simulator to see how it works.
    Code:
       WordA  VAR WORD BANK0 SYSTEM
       WordB  VAR WORD BANK0 SYSTEM
       WordC  VAR WORD BANK0 SYSTEM
       Counts VAR BYTE BANK0 SYSTEM
    
       GOTO Main        ' jump to Main
    
       ' shifts bits left from WordA to WordB to WordC with highest bit
       ' in WordC being trashed.
    ASM
    Rotate  macro
        rlf WordA,f     ; msb of lowbyte into carry
        rlf WordA+1,f   ; carry into lsb of highbyte, msb of highbyte into carry
        rlf WordB,f     ; carry into lsb of lowbyte, msb of lowbyte into carry
        rlf WordB+1,f   ; carry into lsb of highbyte, msb of highbyte into carry
        rlf WordC,f     ; carry into lsb of lowbyte, msb of lowbyte into carry
        rlf WordC+1,f   ; carry into lsb of highbyte, msb of highbyte into carry
        bcf STATUS,C    ; trash msb of WordC to prevent shifting into WordA lsb
        decfsz Counts,f ; decrement shift counter
        goto $-D'8'     ; keep shifting until Counts = 0
        endm
    ENDASM
    
    
    Main:
        ' starting 48-bit value = 1
        WordA = 1     ' load low word
        WordB = 0     ' load mid word
        WordC = 0     ' load high word
        Counts = 47   ' shift 48-bit value left by Counts
        @ Rotate      ' do it
        ' resulting 48-bit value = $800000000000
        
    Here:
        GOTO Here   ' sit & spin after test
        END
    This can be expanded to work on any number of variables. The only real limitation is available RAM &
    PBP system variables.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    cesurcelik's Avatar
    cesurcelik Guest


    Did you find this post helpful? Yes | No

    Default

    @bruce
    i thank you for your reply
    it works perfectly

    cesur

Similar Threads

  1. 2D Matrix Rotation
    By Art in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 16th February 2010, 12:34
  2. PIC-LCD3310 Pin Outs for PicBasic(pro)
    By douglas.mauro in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 13th March 2009, 07:17
  3. Proton+ and PicBasicpro
    By Rob Martin in forum mel PIC BASIC Pro
    Replies: 34
    Last Post: - 9th November 2007, 07:58
  4. Encoder rotation calculation
    By Stefan in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 31st October 2007, 07:37
  5. mikrobasic to picbasicpro
    By nicolasronan in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th September 2006, 22:34

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts