;  Library glue code between assembler and C for the GNU regular
;  expression library. Edwin Hoogerbeets 18/07/89
;
;  This file may be copied and distributed under the GNU Public
;  Licence. See the comment at the top of regex.c for details.
;
;  Adapted from Elib by Jim Mackraz, mklib by Edwin Hoogerbeets, and the
;  GNU regular expression package by the Free Software Foundation.

        include 'exec/types.i'

setup   macro
        movem.l d2/d3/d4-d7/a2-a6,-(sp)
        jsr     _geta4
        endm

push    macro
        move.l  \1,-(sp)
        endm

fix     macro
        ifc     '\1',''
                mexit
        endc
        ifle    \1-8
                addq.l  #\1,sp
        endc
        ifgt    \1-8
                lea     \1(sp),sp
        endc
        endm

restore macro
        fix     \1
        movem.l (sp)+,d2/d3/d4-d7/a2-a6
        rts
        endm

        dseg

        public  _libfunctab
_libfunctab:
        dc.l    myopen
        dc.l    myclose
        dc.l    myexpunge
        dc.l    $0000
        dc.l    Xre_initialize_buffer
        dc.l    Xre_terminate_buffer
        dc.l    Xre_compile_pattern
        dc.l    Xre_compile_fastmap
        dc.l    Xre_search
        dc.l    Xre_search_2
        dc.l    Xre_match
        dc.l    Xre_match_2
        dc.l    $ffffffff

        cseg

        ;--- library functions
        public  _myOpen
        public  _myClose
        public  _myExpunge
        public  _re_initialize_buffer
        public  _re_terminate_buffer
        public  _re_compile_pattern
        public  _re_compile_fastmap
        public  _re_search
        public  _re_search_2
        public  _re_match
        public  _re_match_2

        public  _geta4

myopen:
        setup
        push a6
        jsr     _myOpen
        restore 4

myclose:
        setup
        push a6
        jsr     _myClose
        restore 4

myexpunge:
        setup
        push a6
        jsr     _myExpunge
        restore 4

Xre_initialize_buffer:
        setup
        push d1
        push d0
        jsr _re_initialize_buffer
        restore 8

Xre_terminate_buffer:
        setup
        push d0
        jsr _re_terminate_buffer
        restore 4

Xre_compile_pattern:
        setup
        push a1
        push a0
        push d1
        push d0
        jsr _re_compile_pattern
        restore 16

Xre_compile_fastmap:
        setup
        push d0
        jsr _re_compile_fastmap
        restore 4

Xre_search:
        setup
        push d3
        push d2
        push a1
        push a0
        push d1
        push d0
        jsr _re_search
        restore 24

Xre_search_2:
        setup
        push d6
        push d5
        push d4
        push d3
        push d2
        push a1
        push a0
        push d1
        push d0
        jsr _re_search_2
        restore 36

Xre_match:
        setup
        push d2
        push a1
        push a0
        push d1
        push d0
        jsr _re_match
        restore 20

Xre_match_2:
        setup
        push d5
        push d4
        push d3
        push d2
        push a1
        push a0
        push d1
        push d0
        jsr _re_match_2
        restore 32

        end
