* ck9asm.a
* ========
* Assembler code to give Kermit access to OS9 service calls 
* that were not supported by the C libraries when it was 
* written prior to the release of OS-9 v2.4
*
* Author: unknown
* Date:   unknown
*
* Version 2.4 now supports signal masking, setting and deleting
* alarms, but still does not provide access to the I$SetStt SS_Break
* SCF driver function which causes a BREAK to be sent. 
*
* As a consequence, and to avoid changing code that handles alarms
* the entire module has been retained.
*
* 27/06/1998 - Change by Martin Gregorie, gregorie@logica.com
*
*              With Ckermit V193 the data area has expanded to
*              more than 64K. Consequently this module has been
*              changed so error exit paths use 32 bit offsets to
*              set the errno global.
*
    psect

sigmask:
        link a5,#$0000
        move.l d1,-(a7)
        move.l d0,d1
        moveq #0,d0
        os9 F$SigMask
        bcs.s sigerr
        moveq #0,d0
sigret
        move.l (a7)+,d1
        unlk a5
        rts
sigerr
		move.l #errno,d2
        move.l d1,0(a6,d2.l)
        moveq #-1,d0
        bra.s sigret

remove_alarm:
        link a5,#$0000
        movem.l d1,-(a7)
        moveq.l #0,d0
        move.w  #A$Delete,d1
        os9     F$Alarm
        exg     d0,d1
        movem.l (a7)+,d1
        bcc.s   return_success
        bra.s   return_error

add_alarm:
        link a5,#$0000
        movem.l d1-d3,-(a7)
        move.l  d0,d3
        move.l  d1,d2
        moveq.l #0,d0
        move.w  #A$Set,d1
        lsl.l   #8,d3                   times 256
        bset.l  #31,d3                  1/256 seconds
        os9     F$Alarm
        exg     d0,d1
        movem.l (a7)+,d1-d3
        bcc.s   return_success

return_error
		move.l  #errno,d2
        move.l  d0,0(a6,d2.l)
        moveq   #-1,d0
        bra.s   ret
return_success
        moveq #0,d0
ret
        unlk a5
        rts

*int    send_break(path) int path;
* sends a break on path using the SS_break setstat call to the driver
* return 0 on success, -1 on error with appropriate errorcode in errno
send_break:
        link a5,#$0000
        movem.l d1,-(a7)
        move.w  #SS_Break,d1
        os9     I$SetStt
        exg     d0,d1
        movem.l (a7)+,d1
        bcc.s   return_success
        bra.s   return_error


    ends
