source: sbliveos2/trunk/drv16/memutil.asm@ 143

Last change on this file since 143 was 142, checked in by ktk, 25 years ago

Import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
Line 
1; $Id: memutil.asm 142 2000-04-23 14:55:46Z ktk $
2
3;/* SCCSID = %W% %E% */
4;/***************************************************************************
5; *
6; Copyright (c) IBM Corporation 1994 - 1997. *
7; *
8; The following IBM OS/2 source code is provided to you solely for the *
9; the purpose of assisting you in your development of OS/2 device drivers. *
10; You may use this code in accordance with the IBM License Agreement *
11; provided in the IBM Device Driver Source Kit for OS/2. *
12; *
13; ***************************************************************************/
14;/*@internal %W%
15; @notes
16; The Watcom __fmemcpy intrinsic function resolves to a movsw instruction
17; which requires 4 clock cycles to move 2 bytes of data. the movsd instruction
18; can move 4 bytes in the same 4 clock cycles. Such a deal !!!!!
19; Since the compiler won't let us write a pragma aux to implement this
20; function, we have written it in assembler. There is also a memfill function
21; that uses the stosd instruction to fill memory with the a value in eax.
22; This function is used to write "silence" into the audio buffer
23;
24; @version %I%
25; @context Unless otherwise noted, all interfaces are Ring-0, 16-bit,
26; <stack context>.
27; @history
28;
29;
30
31.386
32.seq
33
34_HEADER segment dword public use16 'DATA'
35_HEADER ends
36
37_DATA segment dword public use16 'DATA'
38_DATA ends
39
40CONST segment dword public use16 'DATA'
41CONST ends
42
43CONST2 segment dword public use16 'DATA'
44CONST2 ends
45
46_BSS segment dword public use16 'BSS'
47_BSS ends
48
49_ENDDS segment dword public use16 'ENDDS'
50_ENDDS ends
51
52_INITDATA segment dword public use16 'ENDDS'
53_INITDATA ends
54
55_ENDINITDATA segment dword public use16 'ENDDS'
56_ENDINITDATA ends
57
58_TEXT segment dword public use16 'CODE'
59_TEXT ends
60
61RMCODE segment dword public use16 'CODE'
62RMCODE ends
63
64_ENDCS segment dword public use16 'CODE'
65_ENDCS ends
66
67_INITTEXT segment dword public use16 'CODE'
68_INITTEXT ends
69
70DGROUP group _HEADER, CONST, CONST2, _DATA, _BSS, _ENDDS, _INITDATA, _ENDINITDATA
71CGROUP group _TEXT, RMCODE, _ENDCS, _INITTEXT
72
73
74_TEXT SEGMENT DWORD PUBLIC USE16 'CODE'
75 assume cs:cgroup, ds:dgroup
76
77
78; void cdecl ddmemmov(PVOID pdest, PVOID psrc, USHORT count);
79
80public _ddmemmov
81_ddmemmov proc near
82
83DEST1_LOW equ [bp+4]
84DEST1_HIGH equ [bp+6]
85SRC1_LOW equ [bp+8]
86SRC1_HIGH equ [bp+0ah]
87BUF1_LEN equ [bp+0ch]
88
89 ; point to parameters and local variables
90 push bp
91 mov bp,sp
92
93 ; save registers
94 push cx
95 push bx
96 push ds
97 push es
98 push si
99 push di
100
101 ; store number of bytes to transfer and calculate number of double words
102 ; and set of transfer value
103 mov bx,BUF1_LEN
104 mov cx,bx
105 shr cx,2
106
107 ; set size in bytes of object to be allocated
108 mov es,DEST1_HIGH
109 mov di,DEST1_LOW
110
111 ; set up pointers to source buffer
112 mov ds,SRC1_HIGH
113 mov si,SRC1_LOW
114
115 ; set up transfer direction
116 cld
117
118 ; do the transfer
119 rep movsd
120
121 ; transfer number of odd bytes
122 mov cx,bx
123 and cx,03h
124 rep movsb
125
126 ;set up return value and restore registers
127 pop di
128 pop si
129 pop es
130 pop ds
131 pop bx
132 pop cx
133 pop bp
134
135 ;done
136 ret
137_ddmemmov endp
138
139
140;VOID memfill(UCHAR *destP, ULONG length, UCHAR value)
141; This function fills a block of memory with a particular value.
142; The function receives address of the memory, the length of the memory, and
143; the fill value as parameters on the stack.
144; The function does not return a value.
145
146public _ddmemfill
147_ddmemfill proc near
148
149DEST2_LOW equ [bp+4]
150DEST2_HIGH equ [bp+6]
151BUF2_LEN equ [bp+8]
152VALUE2 equ [bp+0ah]
153
154 ; point to parameters and local variables
155 push bp
156 mov bp,sp
157
158 ; save registers
159 push bx
160 push cx
161 push es
162 push di
163
164 ; store number of bytes to transfer and calculate number of double words
165 ; and set of transfer value
166 mov bx,BUF2_LEN
167 mov cx,bx
168 shr cx,2
169
170 ; set size in bytes of object to be allocated
171 mov es,DEST2_HIGH
172 mov di,DEST2_LOW
173
174 ; set up value
175 mov ax,VALUE2
176 shl eax,010h
177 mov ax,VALUE2
178
179 ; set up transfer direction
180 cld
181
182 ; do the transfer
183 rep stosd
184
185 ; transfer number of odd bytes
186 mov cx,bx
187 and cx,03h
188 rep stosb
189
190 ;set up return value and restore registers
191 pop di
192 pop es
193 pop cx
194 pop bx
195 pop bp
196
197 ;done
198 ret
199_ddmemfill endp
200
201_TEXT ENDS
202
203 end
Note: See TracBrowser for help on using the repository browser.