source: GPL/branches/uniaud32-next/include/stacktoflat.h

Last change on this file was 667, checked in by Paul Smedley, 5 years ago

Remove remaining support for non-KEE builds

File size: 2.7 KB
Line 
1/* $Id: stacktoflat.h,v 1.1.1.1 2003/07/02 13:56:58 eleph Exp $ */
2/*
3 * Header for SS / DS conversion routines
4 *
5 * (C) 2000-2002 InnoTek Systemberatung GmbH
6 * (C) 2000-2001 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
21 * USA.
22 *
23 */
24
25#ifndef __STACKTOFLAT_H__
26#define __STACKTOFLAT_H__
27
28extern ULONG stacksel; //16 bits stack selector
29#pragma aux stacksel "stacksel"
30
31extern ULONG stackbase; //32 bits stackbase
32#pragma aux stackbase "stackbase"
33
34//Convert 16:16 stack based address to 0:32 flat addresss
35#define __Stack16ToFlat(addr) (LINEAR)((ULONG)(addr&0xffff) + stackbase)
36
37// Convert 16:16 pointer to 16:32
38char FAR48 *MAKE_FARPTR32(FARPTR16 addr1616);
39#pragma aux MAKE_FARPTR32 = \
40 "movzx edx, ax" \
41 "shr eax, 16" \
42 "mov fs, ax" \
43 parm [eax] \
44 value [fs edx];
45
46//Only valid for pointer previously constructed by __Make48Pointer!!
47//(upper 16 bits of 32 bits offset must be 0)
48FARPTR16 MAKE_FARPTR16(void FAR48 *addr1632);
49#pragma aux MAKE_FARPTR16 = \
50 "mov ax, gs" \
51 "shl eax, 16" \
52 "mov ax, dx" \
53 parm [gs edx] \
54 value [eax];
55
56FARPTR16 MAKE_FARPTR16_STACK(LINEAR offset);
57#pragma aux MAKE_FARPTR16_STACK = \
58 "mov ax, ss" \
59 "shl eax, 16" \
60 "mov ax, dx" \
61 parm [edx] \
62 value [eax];
63
64char FAR48 *MAKE_FARPTR32_STACK(LINEAR offset);
65#pragma aux MAKE_FARPTR32_STACK = \
66 "push ss" \
67 "pop fs" \
68 parm [eax] \
69 value [fs eax];
70
71#define MAKE_FP16(sel, offset) ((sel << 16) | (offset & 0xffff) )
72
73USHORT GETFARSEL(char FAR48 *addr1632);
74#pragma aux GETFARSEL = \
75 "mov ax, gs" \
76 parm [gs edx] \
77 value [ax];
78
79ULONG GETFAROFFSET(char FAR48 *addr1632);
80#pragma aux GETFAROFFSET = \
81 "mov eax, edx" \
82 parm [gs edx] \
83 value [eax];
84
85//SvL: Only works for DS & SS ptrs!
86ULONG GETFLATPTR(char FAR48 *ptr);
87
88#define FLATPTR(a) GETFLATPTR((char FAR48 *)a)
89
90#define FlatToSel(addr32) ((stacksel << 16) | (((ULONG)addr32 - stackbase) & 0xffff))
91
92#endif
Note: See TracBrowser for help on using the repository browser.