143561Skato#
243561Skato# Copyright (c) 1998 Robert Nordier
343561Skato# All rights reserved.
443561Skato#
543561Skato# Redistribution and use in source and binary forms are freely
643561Skato# permitted provided that the above copyright notice and this
743561Skato# paragraph and the following disclaimer are duplicated in all
843561Skato# such forms.
943561Skato#
1043561Skato# This software is provided "AS IS" and without any express or
1143561Skato# implied warranties, including, without limitation, the implied
1243561Skato# warranties of merchantability and fitness for a particular
1343561Skato# purpose.
1443561Skato#
1543561Skato
1650477Speter# $FreeBSD$
1743561Skato
1843561Skato#
1943561Skato# BTX V86 interface.
2043561Skato#
2143561Skato
2243561Skato#
2343561Skato# Globals.
2443561Skato#
2543561Skato		.global __v86int
2643561Skato#
2743561Skato# Fields in V86 interface structure.
2843561Skato#
2943561Skato		.set V86_CTL,0x0		# Control flags
3043561Skato		.set V86_ADDR,0x4		# Int number/address
3143561Skato		.set V86_ES,0x8			# V86 ES
3243561Skato		.set V86_DS,0xc			# V86 DS
3343561Skato		.set V86_FS,0x10		# V86 FS
3443561Skato		.set V86_GS,0x14		# V86 GS
3543561Skato		.set V86_EAX,0x18		# V86 EAX
3643561Skato		.set V86_ECX,0x1c		# V86 ECX
3743561Skato		.set V86_EDX,0x20		# V86 EDX
3843561Skato		.set V86_EBX,0x24		# V86 EBX
3943561Skato		.set V86_EFL,0x28		# V86 eflags
4043561Skato		.set V86_EBP,0x2c		# V86 EBP
4143561Skato		.set V86_ESI,0x30		# V86 ESI
4243561Skato		.set V86_EDI,0x34		# V86 EDI
4343561Skato#
4443561Skato# Other constants.
4543561Skato#
4643561Skato		.set INT_V86,0x31		# Interrupt number
4743561Skato		.set SIZ_V86,0x38		# Size of V86 structure
4843561Skato#
4943561Skato# V86 interface function.
5043561Skato#
5143561Skato__v86int:	popl __v86ret			# Save return address
5243561Skato		pushl $__v86			# Push pointer
5343561Skato		call __v86_swap			# Load V86 registers
5443561Skato		int $INT_V86			# To BTX
5543561Skato		call __v86_swap			# Load user registers
5643561Skato		addl $0x4,%esp			# Discard pointer
5743561Skato		pushl __v86ret			# Restore return address
5843561Skato		ret 				# To user
5943561Skato#
6043561Skato# Swap V86 and user registers.
6143561Skato#
6243561Skato__v86_swap:	xchgl %ebp,0x4(%esp,1)		# Swap pointer, EBP
6343561Skato		xchgl %eax,V86_EAX(%ebp)	# Swap EAX
6443561Skato		xchgl %ecx,V86_ECX(%ebp)	# Swap ECX
6543561Skato		xchgl %edx,V86_EDX(%ebp)	# Swap EDX
6643561Skato		xchgl %ebx,V86_EBX(%ebp)	# Swap EBX
6743561Skato		pushl %eax			# Save
6843561Skato		pushf 				# Put eflags
6943561Skato		popl %eax			#  in EAX
7043561Skato		xchgl %eax,V86_EFL(%ebp)	# Swap
7143561Skato		pushl %eax			# Put EAX
7243561Skato		popf 				#  in eflags
7343561Skato		movl 0x8(%esp,1),%eax		# Load EBP
7443561Skato		xchgl %eax,V86_EBP(%ebp)	# Swap
7543561Skato		movl %eax,0x8(%esp,1)		# Save EBP
7643561Skato		popl %eax			# Restore
7743561Skato		xchgl %esi,V86_ESI(%ebp)	# Swap ESI
7843561Skato		xchgl %edi,V86_EDI(%ebp)	# Swap EDI
7943561Skato		xchgl %ebp,0x4(%esp,1)		# Swap pointer, EBP
8043561Skato		ret				# To caller
8143561Skato#
8243561Skato# V86 interface structure.
8343561Skato#
8443561Skato		.comm __v86,SIZ_V86
8543561Skato		.comm __v86ret,4
86