*********************************************************************
*                                                                   *
*         ESEMPIO SU COME RICHIAMARE LE FUNZIONI di ARP:            *
*         1) ArpAllocFreq                                           *
*         2) FileRequest                                            *
*         3) Printf                                                 *
*         4) Puts                                                   *
*         DA LINGUAGGIO ASSEMBLER                                   *
*         (Assemblatori Lattice, Devpac - adattabile ad altri)      *
*                                                                   *
*********************************************************************

    include "exec/funcdef.i"                    * togliere per DevPac
    include "exec/exec_lib.i"
    include "libraries/arpbase.i"

         section code

_main    OPENARP                                * apri ARP, tramite macro
         jsr    _LVOArpAllocFreq(a6)            * alloca File Requester
         tst.l  d0
         beq.s  fine                            * se fallisce, esci
         move.l d0,a5
         move.l a5,a0
         lea    titolo(pc),a1
         move.l a1,fr_Hail(a0)
         jsr    _LVOFileRequest(a6)             * chiamiamo il Requester
         tst.l  d0
         beq.s  MA_NO                           * se selezionato CANCEL
         move.l fr_Dir(a5),a1
         lea    stringa(pc),a0
         moveq  #0,d0
loop     move.b (a1)+,0(a0,d0.l)                * stringa=Dir
         addq.l #1,d0
         tst.b  -1(a1)
         bne.s  loop
         move.l fr_File(a5),a1
         lea    stringa(pc),a0
         move.l a0,pointer
         jsr    _LVOTackOn(a6)                  * stringa=Dir+File
         lea    selez(pc),a0
         lea    pointer(pc),a1
         jsr    _LVOPrintf(a6)                  * printf(selez,stringa)
         bra.s  fine
MA_NO:   lea    cancel(pc),a1
         jsr    _LVOPuts(a6)                    * puts(cancel)
fine:    move.l a6,a1
         move.l 4,a6
         jsr    _LVOCloseLibrary(a6)            * CloseLibrary(ArpBase)
         MOVEM.L (sp)+,d0/a0                    * OPENARP richiede questo
         rts

pointer ds.l    1

stringa ds.b    256
    cnop    0,2

arpname dc.b 'arp.library',0
    cnop    0,2

selez   dc.b    'Hai selezionato %s ',10,0
    cnop    0,2

cancel  dc.b    'Hai selezionato CANCEL',0
    cnop    0,2

titolo  dc.b    'ArpFromAssembler!',0
    cnop    0,2

        END
