Hot!Microchip PIC16F54 Org

Author
Bucky Amateur PIC Assembly Programmer
Super Member
  • Total Posts : 537
  • Reward points : 0
  • Joined: 2016/12/18 10:59:17
  • Location: 0
  • Status: offline
2018/02/16 09:33:55 (permalink)
0

Microchip PIC16F54 Org

porta equ 05
org 1FF
goto Start
org 0
 
This is from John Morton PIC book. Declaration section of program.
 
What is the org doing?
 
What happens when 'org 1FF' executes or does whatever it does do?
 
There is a 'RETLW 0' at end of subroutine in program.
 

Bucky-Amateur PIC Assembly Programmer
 
 
 
 
 
 

 
 
 
 
 
#1

19 Replies Related Threads

    Bucky Amateur PIC Assembly Programmer
    Super Member
    • Total Posts : 537
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: Microchip PIC16F54 Org 2018/02/16 09:38:01 (permalink)
    0
    Program A
    ;************************************
    ; written by: John Morton *
    ; date: 21/07/97 *
    ; version: 1.0 *
    ; file saved as: LedOn *
    ; for PIC16F54 *
    ; clock frequency: 3.82 MHz *
    ;************************************
    ; PROGRAM FUNCTION:To turn on an LED.
    list P=16F54
    include “c:\pic\p16f5x.inc”
    __config _RC_OSC & _WDT_OFF & _CP_OFF
    ;============
    ; Declarations:
    porta equ 05
    org 1FF
    goto Start
    org 0
    ;============
    ; Subroutines:
    Init clrf porta ; resets Port A
    movlw b’0000’ ; RA0: LED, RA1-3: not connected
    tris porta
    retlw 0
    ;============
    ; Program Start:
    Start call Init ; sets up inputs and outputs
    Main bsf porta, 0 ; turns on LED
    7
    Sample programs
    goto Main ; loops back to Main
    END



    Bucky-Amateur PIC Assembly Programmer
     
     
     
     
     
     

     
     
     
     
     
    #2
    Bucky Amateur PIC Assembly Programmer
    Super Member
    • Total Posts : 537
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: Microchip PIC16F54 Org 2018/02/16 09:48:18 (permalink)
    0
    Program A
    ;************************************
    ; written by: John Morton *
    ; date: 21/07/97 *
    ; version: 1.0 *
    ; file saved as: LedOn *
    ; for PIC16F54 *
    ; clock frequency: 3.82 MHz *
    ;************************************
    ; PROGRAM FUNCTION:To turn on an LED.
    list P=16F54
    include “c:\pic\p16f5x.inc”
    __config _RC_OSC & _WDT_OFF & _CP_OFF
    ;============
    ; Declarations:
    porta equ 05
    org 1FF
    goto Start
    org 0
    ;============
    ; Subroutines:
    Init clrf porta ; resets Port A
    movlw b’0000’ ; RA0: LED, RA1-3: not connected
    tris porta
    retlw 0
    ;============
    ; Program Start:
    Start call Init ; sets up inputs and outputs
    Main bsf porta, 0 ; turns on LED
    7
    Sample programs
    goto Main ; loops back to Main
    END
    Program B

     
    Used Insert Code but still lost formatting.
     
    BTW We rewrote this program to compile in MPLAB X. This is program copied from book .PDF.
    post edited by Champion - 2018/02/16 09:51:05

    Bucky-Amateur PIC Assembly Programmer
     
     
     
     
     
     

     
     
     
     
     
    #3
    mbrowning
    Just a Member
    • Total Posts : 910
    • Reward points : 0
    • Joined: 2005/03/16 14:32:56
    • Location: Melbourne, FL
    • Status: offline
    Re: Microchip PIC16F54 Org 2018/02/16 09:56:13 (permalink)
    +2 (2)
    ORG (for origin) is a directive telling the compiler to place the next instruction at the requested address.
     
    The PIC16F54 reset vector is 0x1ff, so "ORG 1FF" places the next instruction at the location the PIC will start at after a reset.
     
    The second ORG tells the compiler to start the remaining code at address 0x000
     
    C:\Program Files (x86)\Microchip\MPLABX\v4.01\mpasmx\docs\MPASM_MPLINK_User_Guide.pdf section 4.51
    post edited by mbrowning - 2018/02/16 09:59:29

    Can't remember. I've slept since then - Mark
    #4
    Bucky Amateur PIC Assembly Programmer
    Super Member
    • Total Posts : 537
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: Microchip PIC16F54 Org 2018/02/16 11:25:09 (permalink)
    0
     
    Does the ORG 0 ever do anything in this program?
     
    Looks like after going to Start the program never comes back up to that line.

    Bucky-Amateur PIC Assembly Programmer
     
     
     
     
     
     

     
     
     
     
     
    #5
    1and0
    Access is Denied
    • Total Posts : 7836
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Microchip PIC16F54 Org 2018/02/16 12:57:48 (permalink)
    +10 (10)

    #6
    mbrowning
    Just a Member
    • Total Posts : 910
    • Reward points : 0
    • Joined: 2005/03/16 14:32:56
    • Location: Melbourne, FL
    • Status: offline
    Re: Microchip PIC16F54 Org 2018/02/16 13:15:05 (permalink)
    +1 (1)
    Let's see -
    At 1ff (1st instruction after reset) there's a jump to Start (GOTO Start)
    At Start there's a call to Init (at 0 because of  ORG 0)
    Init RETURNs from the call (RETLW 0) to the instruction after the call which is:
    The next instruction at address Main which does a little work
    Then a GOTO Main to repeat the work
     
    So location 0 is executed once, never to be seen again. (until the next reset)
     

    Can't remember. I've slept since then - Mark
    #7
    Bucky Amateur PIC Assembly Programmer
    Super Member
    • Total Posts : 537
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: Microchip PIC16F54 Org 2018/02/16 14:13:09 (permalink)
    0
     
    Okay. Up to speed now.
     
    ORG and addresses it goes to are 'not visible on the program' so
     
    you have to follow two trails.
     
    Code trail and ORG trail. Check them against each other.
     
    All cleared up. Thanks!

    Bucky-Amateur PIC Assembly Programmer
     
     
     
     
     
     

     
     
     
     
     
    #8
    PStechPaul
    Super Member
    • Total Posts : 1753
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: Microchip PIC16F54 Org 2018/02/16 16:35:14 (permalink)
    +1 (1)
    I question the reason for using the ancient PIC16F54-7-9 for learning. It is rather unique among PICs in that the reset vector is located at the end of Flash ROM (1FFF, or 7FFF), whereas most PICs have it at 0000h, with interrupt vectors at 0004h and perhaps 0008h. The PIC16F5x does not even have interrupt capability. This is like learning to drive by first using a horse and buggy, then a go-cart, and then... :)
    post edited by PStechPaul - 2018/02/16 20:40:16

     
    #9
    qɥb
    Monolothic Member
    • Total Posts : 2419
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: online
    Re: Microchip PIC16F54 Org 2018/02/16 16:47:02 (permalink)
    +2 (2)
    PStechPaul
    I question the reason for using the ancient PIC16F54-7-9 for learning.

    ditto, but we know this OP likes doing this backwards.
     
    It is rather unique among PICs in that the reset vector is located at the end of RAM

    RAM -> ROM
     

    PicForum "it just works"
    #10
    Bucky Amateur PIC Assembly Programmer
    Super Member
    • Total Posts : 537
    • Reward points : 0
    • Joined: 2016/12/18 10:59:17
    • Location: 0
    • Status: offline
    Re: Microchip PIC16F54 Org 2018/02/17 11:12:22 (permalink)
    0
     
    Thank to Browning for getting me unstuck.
     
    Figured out to look in Morton book I'm using did find ORG is covered in first chapter.
     
    Starts on ORG an page 17
     
    Goal is to finish making template which I blew past and then get back to experiments.
     
    Next is LED with pushbutton.

    Bucky-Amateur PIC Assembly Programmer
     
     
     
     
     
     

     
     
     
     
     
    #11
    MBedder
    Circuit breaker
    • Total Posts : 6324
    • Reward points : 0
    • Joined: 2008/05/30 11:24:01
    • Location: Zelenograd, Russia
    • Status: offline
    Re: Microchip PIC16F54 Org 2018/02/17 11:37:16 (permalink)
    +5 (5)
    489 posts and still no LED with pushbutton? Cool! LoL
    #12
    MBedder
    Circuit breaker
    • Total Posts : 6324
    • Reward points : 0
    • Joined: 2008/05/30 11:24:01
    • Location: Zelenograd, Russia
    • Status: offline
    Re: Microchip PIC16F54 Org 2018/02/17 11:41:57 (permalink)
    +5 (5)
    Oh, now I see - this is a "famous" banned picmicrocontrolleruser who used to bomb this forum with his absolutely dumb posts. Welcome back, dude LoL
     
    #13
    dan1138
    Super Member
    • Total Posts : 2721
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: Microchip PIC16F54 Org 2018/02/17 19:42:49 (permalink)
    +1 (1)
    MBedder

    Oh, now I see - this is a "famous" banned picmicrocontrolleruser who used to bomb this forum with his absolutely dumb posts. Welcome back, dude


    As an absolutely dumb person I resent the association with the Original Poster. LoL
    #14
    PStechPaul
    Super Member
    • Total Posts : 1753
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: Microchip PIC16F54 Org 2018/02/17 21:10:53 (permalink)
    +1 (1)
    "Captain Unconvincible" !

     
    #15
    MBedder
    Circuit breaker
    • Total Posts : 6324
    • Reward points : 0
    • Joined: 2008/05/30 11:24:01
    • Location: Zelenograd, Russia
    • Status: offline
    Re: Microchip PIC16F54 Org 2018/02/17 23:36:25 (permalink)
    +2 (2)
    Certainly - the same dude - "Captain Invincible Unconvincible" LoL
    #16
    drh
    Arrrr
    • Total Posts : 1048
    • Reward points : 0
    • Joined: 2004/07/12 11:43:22
    • Location: Laguna Niguel, Calif. USA
    • Status: online
    Re: Microchip PIC16F54 Org 2018/02/18 07:47:08 (permalink)
    0
    Marketing executive in training? grin: grin

    David
    #17
    MBedder
    Circuit breaker
    • Total Posts : 6324
    • Reward points : 0
    • Joined: 2008/05/30 11:24:01
    • Location: Zelenograd, Russia
    • Status: offline
    Re: Microchip PIC16F54 Org 2018/02/18 08:00:15 (permalink)
    +2 (2)
    No, just a brainless nerd.
    #18
    drh
    Arrrr
    • Total Posts : 1048
    • Reward points : 0
    • Joined: 2004/07/12 11:43:22
    • Location: Laguna Niguel, Calif. USA
    • Status: online
    Re: Microchip PIC16F54 Org 2018/02/18 11:28:27 (permalink)
    0
    MBedder
    No, just a brainless nerd.




    Is there a difference?

    David
    #19
    PStechPaul
    Super Member
    • Total Posts : 1753
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Jump to:
    © 2018 APG vNext Commercial Version 4.5