Trying to learn Assembly


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,694


    Did you find this post helpful? Yes | No

    Default Re: Trying to learn Assembly

    The problem must be with moving the config data to the port.


    Code:
     MOVLW B'00011110' ;Set RA<4:1> H
     BANKSEL LATA    
     MOVWF LATA
    Warning I'm not a teacher

  2. #2
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Trying to learn Assembly

    You did a BANKSEL TRISA and configured that register, then you loaded W and tried to shove it into PORTA register without resetting the Bank Select Register. TRISA is in BANK 1 while PORTA is in BANK 0. Without selecting BANK 0 with "BANKSEL PORTA" you simply wrote over your TRISA; TRISA & PORTA share the same Register address, though in different Banks.

    BANKSEL PORTA
    MOVLW B'00011110
    MOVWF PORTA

  3. #3
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Trying to learn Assembly

    Got to thinking after posting, I gave you an answer, but didn't share any knowledge.

    In the Data Sheet there is a section called 3.0 Memory Organization. On page 23, Table 3.3 shows where SFR are stored; both Bank# and Address#. You should be able to look at that Table and see PORTA located in BANK 0 at address 000Ch. Next row in BANK 1 you see TRISA at address 008Ch, but the same position within the BANK. Next you can see TRISA in the same position in BANK 2.

    Using BANKSEL is a shortcut that allows the Compiler to find the proper BANK for you. In the Instruction Summary, Section 24, Table 24-3 lists the Assembly Instructions applicable to this PIC. Towards the bottom under the heading Literal Operations is the command MOVLB. If you know TRISA is in BANK 1 you can:

    MOVLB 0x01

    Page 272 shows the expanded explanation of MOVLB.

    I hope this helps you better understand how the Banking system works (at least in the PIC family).

Similar Threads

  1. How/where to learn Assembly?
    By HankMcSpank in forum General
    Replies: 6
    Last Post: - 9th August 2011, 18:40
  2. How do you learn best?
    By T.Jackson in forum Off Topic
    Replies: 41
    Last Post: - 30th May 2008, 15:32
  3. How to learn assembely?
    By amindzo in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 26th May 2007, 22:23
  4. Who wants to learn...
    By Stoverus in forum Off Topic
    Replies: 1
    Last Post: - 21st October 2006, 08:08
  5. Trying to learn the tricks of the trade
    By Rhatidbwoy in forum mel PIC BASIC
    Replies: 1
    Last Post: - 16th October 2005, 20:41

Members who have read this thread : 0

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