/*
 this file was changed or created for the DOS32 library for DJGPP on 5.10.1996
 new created files are copyright 1996 by C.Lageman, see docs.doc for details
*/
/*
   This file is the same like exceptn.s - only without exception handlers

*/
        .file "noexcept.s"
        .text


/*
      bios ctrl-break
*/
int1b:
      pushl    %ds
      cs
      movw     ___dos32_ds,%ds
      testb    $1,___dos32_cbreak_mode
      jz       cbreak_exit
      testb    $2,___dos32_cbreak_mode
      jz       1f
      movb     $1,___dos32_cbreak_counter
1:
      popl     %ds
      iret

cbreak_exit:
      movl     $cbreakmsg,%ecx
      movb     $6,%ah
1:
      movb     (%ecx),%dl
      orb      %dl,%dl
      jz       2f
      incl     %ecx
      int      $0x21
      jmp      1b
2:    movw     $0x4c01,%ax
      int      $0x21
/*
      dos ctrl-c / ctrl - break
      this is faked by just using the identical int1b handler
int23:
      jmp      int1b
*/

/*
      critical error handler with 3 retries (remove retrys ?)
*/
int24:
        testb   $0x80,%ah
        jnz     fail_int24
        pushl   %ds
        pushl   %esi
        cs
        movw    ___dos32_ds,%ds
        cmpb    errordrive,%al
        movl    $error_retries,%esi
        je      1f
        movb    %al,errordrive
        movb    $0,(%esi)
1:      incb    (%esi)
        cmpb    $3,(%esi)
        popl    %esi
        popl    %ds
        ja      fail_int24
        movb    $1,%al
        clc
        lret
fail_int24:
        movb    $3,%al
        clc
        lret

        .data
errordrive:
        .byte   0xff
        .lcomm  error_retries,1

cbreakmsg:
        .ascii  "Exit due to <CTRL-BREAK>"
        .byte   13,10,0

        .global ___dos32_new_ints
___dos32_new_ints:
        .byte   0x1b
        .long   int1b
        .byte   0x23
        .long   int1b
        .byte   0x24
        .long   int24
        .byte   0xff
/*
************************* end of noexcept.s **********************************
*/
