199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome# Copyright (c) 1998 Robert Nordier
199767f8919635c4928607450d9e0abb932109ceToomas Soome# All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome# Redistribution and use in source and binary forms are freely
199767f8919635c4928607450d9e0abb932109ceToomas Soome# permitted provided that the above copyright notice and this
199767f8919635c4928607450d9e0abb932109ceToomas Soome# paragraph and the following disclaimer are duplicated in all
199767f8919635c4928607450d9e0abb932109ceToomas Soome# such forms.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome# This software is provided "AS IS" and without any express or
199767f8919635c4928607450d9e0abb932109ceToomas Soome# implied warranties, including, without limitation, the implied
199767f8919635c4928607450d9e0abb932109ceToomas Soome# warranties of merchantability and fitness for a particular
199767f8919635c4928607450d9e0abb932109ceToomas Soome# purpose.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome# $FreeBSD$
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome# BTX V86 interface.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome# Globals.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome .global __v86int
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome# Fields in V86 interface structure.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome .set V86_CTL,0x0 # Control flags
199767f8919635c4928607450d9e0abb932109ceToomas Soome .set V86_ADDR,0x4 # Int number/address
199767f8919635c4928607450d9e0abb932109ceToomas Soome .set V86_ES,0x8 # V86 ES
199767f8919635c4928607450d9e0abb932109ceToomas Soome .set V86_DS,0xc # V86 DS
199767f8919635c4928607450d9e0abb932109ceToomas Soome .set V86_FS,0x10 # V86 FS
199767f8919635c4928607450d9e0abb932109ceToomas Soome .set V86_GS,0x14 # V86 GS
199767f8919635c4928607450d9e0abb932109ceToomas Soome .set V86_EAX,0x18 # V86 EAX
199767f8919635c4928607450d9e0abb932109ceToomas Soome .set V86_ECX,0x1c # V86 ECX
199767f8919635c4928607450d9e0abb932109ceToomas Soome .set V86_EDX,0x20 # V86 EDX
199767f8919635c4928607450d9e0abb932109ceToomas Soome .set V86_EBX,0x24 # V86 EBX
199767f8919635c4928607450d9e0abb932109ceToomas Soome .set V86_EFL,0x28 # V86 eflags
199767f8919635c4928607450d9e0abb932109ceToomas Soome .set V86_EBP,0x2c # V86 EBP
199767f8919635c4928607450d9e0abb932109ceToomas Soome .set V86_ESI,0x30 # V86 ESI
199767f8919635c4928607450d9e0abb932109ceToomas Soome .set V86_EDI,0x34 # V86 EDI
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome# Other constants.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome .set INT_V86,0x31 # Interrupt number
199767f8919635c4928607450d9e0abb932109ceToomas Soome .set SIZ_V86,0x38 # Size of V86 structure
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome# V86 interface function.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome__v86int: popl __v86ret # Save return address
199767f8919635c4928607450d9e0abb932109ceToomas Soome pushl $__v86 # Push pointer
199767f8919635c4928607450d9e0abb932109ceToomas Soome call __v86_swap # Load V86 registers
199767f8919635c4928607450d9e0abb932109ceToomas Soome int $INT_V86 # To BTX
199767f8919635c4928607450d9e0abb932109ceToomas Soome call __v86_swap # Load user registers
199767f8919635c4928607450d9e0abb932109ceToomas Soome addl $0x4,%esp # Discard pointer
199767f8919635c4928607450d9e0abb932109ceToomas Soome pushl __v86ret # Restore return address
199767f8919635c4928607450d9e0abb932109ceToomas Soome ret # To user
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome# Swap V86 and user registers.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome__v86_swap: xchgl %ebp,0x4(%esp,1) # Swap pointer, EBP
199767f8919635c4928607450d9e0abb932109ceToomas Soome xchgl %eax,V86_EAX(%ebp) # Swap EAX
199767f8919635c4928607450d9e0abb932109ceToomas Soome xchgl %ecx,V86_ECX(%ebp) # Swap ECX
199767f8919635c4928607450d9e0abb932109ceToomas Soome xchgl %edx,V86_EDX(%ebp) # Swap EDX
199767f8919635c4928607450d9e0abb932109ceToomas Soome xchgl %ebx,V86_EBX(%ebp) # Swap EBX
199767f8919635c4928607450d9e0abb932109ceToomas Soome pushl %eax # Save
199767f8919635c4928607450d9e0abb932109ceToomas Soome pushf # Put eflags
199767f8919635c4928607450d9e0abb932109ceToomas Soome popl %eax # in EAX
199767f8919635c4928607450d9e0abb932109ceToomas Soome xchgl %eax,V86_EFL(%ebp) # Swap
199767f8919635c4928607450d9e0abb932109ceToomas Soome pushl %eax # Put EAX
199767f8919635c4928607450d9e0abb932109ceToomas Soome popf # in eflags
199767f8919635c4928607450d9e0abb932109ceToomas Soome movl 0x8(%esp,1),%eax # Load EBP
199767f8919635c4928607450d9e0abb932109ceToomas Soome xchgl %eax,V86_EBP(%ebp) # Swap
199767f8919635c4928607450d9e0abb932109ceToomas Soome movl %eax,0x8(%esp,1) # Save EBP
199767f8919635c4928607450d9e0abb932109ceToomas Soome popl %eax # Restore
199767f8919635c4928607450d9e0abb932109ceToomas Soome xchgl %esi,V86_ESI(%ebp) # Swap ESI
199767f8919635c4928607450d9e0abb932109ceToomas Soome xchgl %edi,V86_EDI(%ebp) # Swap EDI
199767f8919635c4928607450d9e0abb932109ceToomas Soome xchgl %ebp,0x4(%esp,1) # Swap pointer, EBP
199767f8919635c4928607450d9e0abb932109ceToomas Soome ret # To caller
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome# V86 interface structure.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#
199767f8919635c4928607450d9e0abb932109ceToomas Soome .comm __v86,SIZ_V86
199767f8919635c4928607450d9e0abb932109ceToomas Soome .comm __v86ret,4