ASM question


Closed Thread
Results 1 to 11 of 11

Thread: ASM question

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107

    Default ASM question

    In an 18F, can I access the ports without worrying about the bank?

    For example:

    if I use

    @ btg portg,4


    Will that always work to replace the PBP instruction

    Toggle PortG.4 ?
    Charles Linquist

  2. #2
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Since all SFR's are located in the Access Bank, use this:

    Code:
    btg  PORTG,4,0

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Whenever you are using something located in the ACCESS bank ...
    The assembler automatically recognizes it and adds the 0 for you.

    @ btg portg,4

    is all you need.
    <br>
    DT

  4. #4
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Yes, the "0" is optional. I prefer to always include it to prevent issues when not working with the Access Bank - as a reminder to use a "1" and to ensure the correct GPR bank is selected in the BSR.

    Working with different MCU's from PIC's to high end ARM's, doing little things like this can prevent major debugging headaches down the road.

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


    Did you find this post helpful? Yes | No

    Default

    Since all SFR's are located in the Access Bank
    Not on ALL 18F parts they're not, so be careful.
    Regards,

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

  6. #6
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    Not on ALL 18F parts they're not, so be careful.
    Yes, many of the newer 3.3V J series (particularly those with USB and/or Ethernet) do have SFR's located in other than the Access Bank. IIRC, Charles uses a PIC18F8722 (or 8723) and in that case, all the SFR's are located in the Access Bank.

    In any event, you have highlighted one of the main reasons PIC's (particularly the PIC16/18) are not my current choice of MCU - too many gotchas, Ram Banks, Code Pages, etc., although the PIC24/dsPIC are somewhat better in this respect. There is something to be said in having 4GB of linear addressing space for both code and data.

  7. #7
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Thank you all.

    And about that linear addressing space and 4MB of FLASH:

    While my coding abilities have not really progressed past the 18Fs, my hardware needs have.

    I have an ARM9 development kit and I'm re-learning 'C' ...
    Charles Linquist

  8. #8
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Just out of curiosity, which ARM9 are you using?

  9. #9
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Just thinking about the old R-M-W problem.
    It would probably be better to ...
    Code:
    @ btg LATG,4
    DT

  10. #10
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    In fact, that is what I wound up doing.

    And Darrel, while I have your ear...

    DT_Ints seems to screw up the ICD2 debugger. I get a "duplicate labels" error just past point where the int handler is inserted.

    I seem to remember something about this in the MPASM manual, but can't find it right now. Is there some secret I need?

    And, I'm assuming I can remove the 'Disable Debug' and 'Enable Debug' labels in DT_INTs18, correct?
    Charles Linquist

  11. #11
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Try this version of DT_INTS-18 ...

    http://www.picbasic.co.uk/forum/show...2826#post82826
    <br>
    DT

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