Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dosmem.S « go32 « sys « libc « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c1956f7678157dd1ba28d8d0f9381fd02a10aab9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* DOSMEM.S */
/*
** Copyright (C) 1993 C.W. Sandmann
**
** This file may be freely distributed as long as the author's name remains.
** Extender environment independent way to set up Real area 1Mb access.
** Procedure takes a single argument %eax which contains the real area offset.
** After call, access may be made with "%gs:(%eax)"
*/
	.text
	.align	2
	.globl dosmemsetup
dosmemsetup:				/* no params, expected ASM call only */
	pushl	%eax
	movzwl	__core_select,%eax
	testl	%eax,%eax
	je	old_go32		/* Image run with pre-DPMI extender */
	movw	%ax,%gs			/* Use real area selector */
	popl	%eax			/* Plus real offset */
	andl	$0x0fffffff,%eax	/* Clear any linear access bits */
	ret
	.align	2,0x90
old_go32:
	push	%ds
	pop	%gs			/* Use arena selector */
	popl	%eax
	orl	$0xe0000000,%eax	/* Plus linear access area */
	ret

	.align	2
	.globl _dosmemget
_dosmemget:				/* long offset, long len, long *buf */
	push	%gs
	movl	8(%esp),%eax		/* offset */
	call	dosmemsetup
	movl	12(%esp),%ecx		/* length */
	movl	16(%esp),%edx		/* arena offset */
	pushl	%esi
	pushl	%edi
	movl	%eax,%esi
	movl	%edx,%edi
	push	%ds
	push	%es
	push	%ds
	pop	%es
	push	%gs
	pop	%ds
	cld
	rep
	movsb				/* move ECX bytes from Real area */
	pop	%es
	pop	%ds
	popl	%edi
	popl	%esi
	pop	%gs
	ret

	.align	2
	.globl _dosmemput
_dosmemput:				/* long *buf, long len, long offset */
	push	%gs
	movl	16(%esp),%eax		/* offset */
	call	dosmemsetup
	movl	12(%esp),%ecx		/* length */
	movl	8(%esp),%edx		/* arena offset */
	pushl	%esi
	pushl	%edi
	movl	%eax,%edi
	movl	%edx,%esi
	push	%es
	push	%gs
	pop	%es
	cld
	rep
	movsb				/* move ECX bytes to Real area */
	pop	%es
	popl	%edi
	popl	%esi
	pop	%gs
	ret

	.align	2			/* 8(bp)    12(bp)   16(bp)    20(bp)    24(bp) */
	.globl	_movedata		/* src_sel, src_ofs, dest_sel, dest_ofs, len    */
_movedata:
	pushl	%ebp
	movl	%esp,%ebp
	pushw	%ds
	pushw	%es
	pushl	%esi
	pushl	%edi

	movl	8(%ebp),%eax
	movw	%ax,%ds
	movl	12(%ebp),%esi

	movl	16(%ebp),%eax
	movw	%ax,%es
	movl	20(%ebp),%edi

	movl	24(%ebp),%ecx
	pushl	%ecx
	shrl	$2,%ecx
	jcxz	no_big_move
	rep
	movsl
no_big_move:
	popl	%ecx
	andl	$3,%ecx
	jcxz	no_little_move
	rep
	movsb
no_little_move:

	popl	%edi
	popl	%esi
	popw	%es
	popw	%ds
	leave
	ret