+;
+; Copyright (c) 1988 Regents of the University of California.
+; All rights reserved.
+;
+; Redistribution and use in source and binary forms are permitted
+; provided that the above copyright notice and this paragraph are
+; duplicated in all such forms and that any documentation,
+; advertising materials, and other materials related to such
+; distribution and use acknowledge that the software was developed
+; by the University of California, Berkeley. The name of the
+; University may not be used to endorse or promote products derived
+; from this software without specific prior written permission.
+; THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+; IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+; WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+;
+; @(#)spintasm.asm 4.1 (Berkeley) 12/4/88
+; The code in this file complete the spint calls
+;
+
+spint struc
+; union REGS
+spint_ax dw 1
+spint_bx dw 1
+spint_cx dw 1
+spint_dx dw 1
+spint_si dw 1
+spint_di dw 1
+spint_cflag dw 1
+; struct SREGS
+spint_es dw 1
+spint_cs dw 1
+spint_ss dw 1
+spint_ds dw 1
+; int intno
+spint_intno dw 1
+; int done
+spint_done dw 1
+; int rc
+spint_rc dw 1
+;
+spint ends
+
+
+ENTER MACRO
+ ; Begin enter
+ push bp
+ mov bp,sp
+
+ push ax
+ push bx
+ push cx
+ push dx
+ push bp
+ push di
+ push si
+ push ds
+ push es
+ pushf
+
+ mov cs:start_sp, sp
+ mov cs:start_ss, ss
+ ; End enter
+ ENDM
+
+LEAVE MACRO
+ ; Begin leave
+ cli
+ mov sp, cs:start_sp
+ mov ss, cs:start_ss
+ sti
+
+ popf
+ pop es
+ pop ds
+ pop si
+ pop di
+ pop bp
+ pop dx
+ pop cx
+ pop bx
+ pop ax
+
+ mov sp,bp
+ pop bp
+ ret
+ ; End leave
+ ENDM
+
+GETREGS MACRO wherefrom
+ mov si, wherefrom
+ mov spint_segment, ds
+ mov spint_offset, si
+
+ mov ax, spint_ax[si]
+ mov bx, spint_bx[si]
+ mov cx, spint_cx[si]
+ mov dx, spint_dx[si]
+ ; XXX mov si, spint_si[si]
+ mov di, spint_di[si]
+ mov es, spint_es[si]
+ ; Now, need to do DS, SI
+ push spint_ds[si]
+ mov si, spint_si[si]
+ pop ds
+ ENDM
+
+
+SETREGS MACRO
+ mov cs:old_si, si
+ mov cs:old_ds, ds
+
+ mov ds, cs:spint_segment
+ mov si, cs:spint_offset
+
+ mov spint_ax[si], ax
+ mov spint_bx[si], bx
+ mov spint_cx[si], cx
+ mov spint_dx[si], dx
+
+ mov spint_si[si], si
+ mov spint_di[si], di
+
+ mov spint_cs[si], cs
+ mov spint_ds[si], ds
+ mov spint_es[si], es
+ mov spint_ss[si], ss
+ ; now, need to do SI, DS
+ mov ax, old_si
+ mov spint_si[si], ax
+ mov ax, old_ds
+ mov spint_ds[si], ax
+ ENDM
+
+