[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::amiga_v1

Title:AMIGA NOTES
Notice:Join us in the *NEW* conference - HYDRA::AMIGA_V2
Moderator:HYDRA::MOORE
Created:Sat Apr 26 1986
Last Modified:Wed Feb 05 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:5378
Total number of notes:38326

1747.0. "Controlling the entry point address" by NAC::GODDARD () Thu Oct 06 1988 00:57

    I've been playing with the assembler on my Amiga and was wondering
    how you control the entry point address of your program. I noticed
    that if I put data before code Metascope starts its display of memory
    at location 0. However, if I reverse the order (of code and data)
    it figures out to begin the memory diplay at the first instruction
    of the program (realtive 0). So, if you bind multiple objects how does
    the linker know where to begin? (Does it just assume that you always
    want to start at realtive 0?)
T.RTitleUserPersonal
Name
DateLines
1747.1first location in first hunkSTAR::BANKSIn Search of MediocrityThu Oct 06 1988 14:0927
    When DOS starts a process, it starts it at the first location in
    the first hunk in the program.  There are no other considerations
    for program start address outside of that constraint.  Note that
    I really mean the first location in the first hunk in the program,
    and not just the first location in the first code hunk in the program.
    
    This means that whatever module you have that contains the startup
    code should be the first module you give to the linker, and probably,
    the first segment within the module (unless you can get the linker
    to sort by segment name or something).
    
    Personal opinion:  This sorta sucks a whole bunch.
    
    A commented excerpt of the DOS library code from the ROM that gets
    called when processes are created/started.  Fortunately, this piece
    looks to be coded in assembler, so it isn't as contorted looking as the
    BCPL stuff: 
    
        ; Looks like all we have to do is find the starting PC (first code
        ; in the first segment of our seglist) and the final PC (the process
        ; exit code), then start the process. (Hunk list BPTR in D6)
    
FF475A          LSL.L   #2,D6                   ; Convert BPTR to APTR
FF475C          MOVEA.L D6,A2                   ; Copy user's seglist pointer
FF475E          LEA     4(A2),A2                ; Get first code address as initial PC
FF4762          LEA     ProcessFinalPC(PC),A3   ; Get final PC
FF4766          JSR     _LVOAddTask(A6)         ; Fire the task up