home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 357.lha / ProgUtils / WaitSig.asm < prev    next >
Assembly Source File  |  1990-03-12  |  2KB  |  113 lines

  1.         opt    c+,l-
  2.  
  3. ;******************************
  4. ;* Wait for a signal             *
  5. ;* © J.Tyberghein 29 sep 89    *
  6. ;******************************
  7.  
  8. SysBase            equ    4
  9.     ;ExecBase routines
  10. _LVOOldOpenLibrary    equ    -408
  11. _LVOCloseLibrary        equ    -414
  12. _LVOWait                    equ    -318
  13.     ;DosBase routines
  14. _LVOOutput                equ    -60
  15. _LVOWrite                equ    -48
  16.  
  17. CALLEXEC    macro
  18.             move.l (SysBase).w,a6
  19.             jsr _LVO\1(a6)
  20.             endm
  21.  
  22. CALLDOS    macro
  23.             move.l DosBase,a6
  24.             jsr _LVO\1(a6)
  25.             endm
  26.  
  27.         lea        DosLib,a1
  28.         CALLEXEC    OldOpenLibrary
  29.         move.l    d0,DosBase
  30.         CALLDOS    Output
  31.         move.l    d0,OutputHandle
  32.  
  33.         move.l    #255,d0
  34.         CALLEXEC    Wait
  35.         lea        Dummy,a0
  36.         bsr        ToString
  37.         bsr        Message
  38.  
  39.         move.l    DosBase,a1
  40.         CALLEXEC    CloseLibrary
  41.         rts
  42.  
  43.  
  44.     ;*** String length ***
  45.     ;a0 = string address
  46.     ;-> d0 = length
  47.     ;***
  48. StrLen:
  49.         moveq        #-1,d0
  50. LoopSL:
  51.         addq.l    #1,d0
  52.         tst.b        (a0)+
  53.         bne.s        LoopSL
  54.         rts
  55.  
  56.     ;*** Convert an int to a string ***
  57.     ;a0 = pointer
  58.     ;d0 = int
  59.     ;-> a0 = int string
  60.     ;***
  61. ToString:
  62.         move.w    d0,d1
  63.         moveq        #0,d2
  64. LoopTS:
  65.         tst.w        d1
  66.         beq.s        EndLTS
  67.         ext.l        d1
  68.         divu        #10,d1
  69.         addq.w    #1,d2
  70.         bra.s        LoopTS
  71. EndLTS:
  72.         move.b    #10,(a0,d2.w)
  73.         move.b    #0,1(a0,d2.w)
  74. Loop2:
  75.         tst.w        d2
  76.         beq.s        End2
  77.         subq.w    #1,d2
  78.         ext.l        d0
  79.         divu        #10,d0
  80.         swap        d0
  81.         add.w        #48,d0
  82.         move.b    d0,(a0,d2.w)
  83.         swap        d0
  84.         bra.s        Loop2
  85. End2:
  86.         rts
  87.  
  88.     ;*** Put a message on the screen ***
  89.     ;a0 = message
  90.     ;***
  91. Message:
  92.         movem.l    a0,-(a7)
  93.         bsr        StrLen
  94.         movem.l    (a7)+,a0
  95.         move.l    d0,d3
  96.         move.l    OutputHandle,d1
  97.         move.l    a0,d2
  98.         CALLDOS    Write
  99.         rts
  100.  
  101.  
  102.     EVEN
  103. DosBase:            dc.l    0
  104. OutputHandle:    dc.l    0
  105.  
  106.     ;Library names
  107. DosLib:            dc.b    "dos.library",0
  108.     EVEN
  109. Dummy:            ds.b    5
  110.  
  111.     END
  112.  
  113.