home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / miscutil / driver.lzh / DRIVER / TESTDEV.ASM < prev   
Assembly Source File  |  1991-11-01  |  2KB  |  121 lines

  1.  
  2. *************************************************************************
  3. *                                    *
  4. *    Copyright (C) 1985, Commodore Amiga Inc.  All rights reserved.    *
  5. *    Permission granted for non-commercial use            *                                *
  6. *                                    *
  7. ************************************************************************/
  8.  
  9.  
  10. *************************************************************************
  11. *
  12. * testdev.asm -- test the mylib.asm code
  13. *
  14. * Source Control
  15. * ------ -------
  16. * $Header: amain.asm,v 31.3 85/10/18 19:04:04 neil Exp $
  17. *
  18. * $Locker: neil $
  19. *
  20. * $Log:    amain.asm,v $
  21. *
  22. ************************************************************************/
  23.  
  24.     INCLUDE    'exec/types.i'
  25.     INCLUDE    'exec/libraries.i'
  26.     INCLUDE    'exec/devices.i'
  27.     INCLUDE    'exec/io.i'
  28.     INCLUDE    'exec/tasks.i'
  29.     INCLUDE    'exec/interrupts.i'
  30.  
  31.     INCLUDE    'asmsupp.i'
  32.     INCLUDE    'mydev.i'
  33.  
  34.  
  35.  
  36.     XDEF    _main
  37.  
  38.     XREF    _printf
  39.     XREF    _AbsExecBase
  40.     XREF    _CreatePort
  41.     XREF    _DeletePort
  42.     XREF    _CreateStdIO
  43.     XREF    _DeleteStdIO
  44.  
  45.     XLIB    OpenDevice
  46.     XLIB    CloseDevice
  47.  
  48.  
  49. _main:
  50.     move.l    _AbsExecBase,a6
  51.  
  52.     ;------ make a reply port
  53.     pea    0
  54.     pea    myName
  55.     jsr    _CreatePort
  56.     addq.l    #8,sp
  57.  
  58.     move.l    d0,Port
  59.     beq.s    main_end
  60.  
  61.     ;------ get an io request
  62.     move.l    d0,-(sp)
  63.     jsr    _CreateStdIO
  64.     addq.l    #4,sp
  65.  
  66.     move.l    d0,Iob
  67.     beq    main_DeletePort
  68.  
  69.     move.l    d0,a1
  70.     move.l    #myName,LN_NAME(a1)
  71.  
  72.     ;------ open the test device: this will bring it in from disk
  73.     lea    myDevName(pc),a0
  74.     moveq.l    #1,d0
  75.     moveq.l    #0,d1
  76.     CALLSYS    OpenDevice
  77.  
  78.     tst.l    d0
  79.     beq.s    1$
  80.  
  81.     ;------ couldn't find the library
  82.     pea    0
  83.     move.l    d0,a0
  84.     move.b    IO_ERROR(a0),3(sp)
  85.     pea    myDevName(pc)
  86.     pea    nodevmsg(pc)
  87.     jsr    _printf
  88.     addq.l    #8,sp
  89.  
  90.     bra    main_DeleteIob
  91.  
  92. 1$:
  93.  
  94.     ;------ close the device
  95.     move.l    Iob,a1
  96.     CALLSYS    CloseDevice
  97.  
  98. main_DeleteIob:
  99.     move.l    Iob,-(sp)
  100.     jsr    _DeleteStdIO
  101.     addq.l    #4,sp
  102.  
  103. main_DeletePort
  104.     move.l    Port,-(sp)
  105.     jsr    _DeletePort
  106.     addq.l    #4,sp
  107.  
  108. main_end:
  109.     rts
  110.  
  111. myDevName:    MYDEVNAME
  112. myName:        dc.b    'testdev',0
  113. nodevmsg:    dc.b    'can not open device "%s": error %ld',10,0
  114. testmsg:    dc.b    'function MYFUNC%ld returned %ld',10,0
  115.  
  116. Port:    dc.l    0
  117. Iob:    dc.l    0
  118.  
  119.     END
  120.