********************************************************************************
*
*       Program:        Relocate
*       Filename:       Main.a
*
*       Usage:          Reloc SFile DFile Loc
*                       - SFile: source filename
*                       - DFile: destination filename
*                       - Loc:   location address (hex)
*
*       Contents:       Relocates an objectfile at address Loc and
*                       writes it into file DFile.
*
*       Language:       68000 Assembler
*
*       Link-instr.:    Objects:   Astartup.o Main.o TestPar.o
*                                  Load_SFile.o Reloc_SFile.o
*                       Libraries: amiga.lib amigavisions.lib
*                       Output:    Reloc
*
*       Author:         Johannes R. Geiss
*
*       Copyright:      Amigavisions
*
*       History:        $HISTORY:
*                       1.3 (17-Oct-92) changed JRG
*                       1.2 (11-Apr-92) bug fixed JRG
*                       1.1 (15-Oct-91) changed JRG
*                       1.0 (20-Jun-91) written JRG
*
*       Version:        $VER: Reloc 1.3 (17-Oct-92)
*
********************************************************************************


*------ Includes
        include 'exec/types.i'
        include 'libraries/dosextens.i'


*------ Imports
        xref    Print
        xref    TestPar
        xref    Load_SFile
        xref    FreeSMem
        xref    Reloc_SFile
        xref    FreeDMem
        xref    _exit


*------ Exports
        xdef    _main
        xdef    Exit_Am


********************************************************************************

        SECTION Reloc

*------ Main procedure
_main   move.l  4(a7),d0                ; restore Parameter string
        beq     RetOK
        movea.l 8(a7),a0

        bsr     TestPar                 ; test parameter string
        bsr     Load_SFile              ; examines and loads SFile
        bsr     Reloc_SFile             ; relocates SFile

        movea.l #Ok,a0                  ; output: OK
        bsr     Print

RetOK   moveq.l #RETURN_OK,d0           ; return-code ok
Exit_Am move.l  d0,-(a7)                ; save return-code
        bsr     FreeDMem                ; free destination file memory
        bsr     FreeSMem                ; free source file memory
        bsr     _exit                   ; exit


********************************************************************************

        section DATA

*------ Datafield
Ok      dc.b    'OK.',$0a,0

        END
