source: cmedia/trunk/Drv16/memutil.asm

Last change on this file was 354, checked in by stevenhl, 17 years ago

Import untested baseline cmedia sources, work products and binaries
Binaries and work products should be deleted from repository.
once new builds are verified to work.

File size: 4.3 KB
Line 
1; $Id: memutil.asm,v 1.1 2000/04/23 14:55:17 ktk Exp $
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
35include ..\include\segments.inc
36
37
38_TEXT SEGMENT DWORD PUBLIC USE16 'CODE'
39 assume cs:cgroup, ds:dgroup
40
41
42; void cdecl ddmemmov(PVOID pdest, PVOID psrc, USHORT count);
43
44public _ddmemmov
45_ddmemmov proc near
46
47DEST1_LOW equ [bp+4]
48DEST1_HIGH equ [bp+6]
49SRC1_LOW equ [bp+8]
50SRC1_HIGH equ [bp+0ah]
51BUF1_LEN equ [bp+0ch]
52
53 ; point to parameters and local variables
54 push bp
55 mov bp,sp
56
57 ; save registers
58 push cx
59 push bx
60 push ds
61 push es
62 push si
63 push di
64
65 ; store number of bytes to transfer and calculate number of double words
66 ; and set of transfer value
67 mov bx,BUF1_LEN
68 mov cx,bx
69 shr cx,2
70
71 ; set size in bytes of object to be allocated
72 mov es,DEST1_HIGH
73 mov di,DEST1_LOW
74
75 ; set up pointers to source buffer
76 mov ds,SRC1_HIGH
77 mov si,SRC1_LOW
78
79 ; set up transfer direction
80 cld
81
82 ; do the transfer
83 rep movsd
84
85 ; transfer number of odd bytes
86 mov cx,bx
87 and cx,03h
88 rep movsb
89
90 ;set up return value and restore registers
91 pop di
92 pop si
93 pop es
94 pop ds
95 pop bx
96 pop cx
97 pop bp
98
99 ;done
100 ret
101_ddmemmov endp
102
103
104;VOID memfill(UCHAR *destP, ULONG length, UCHAR value)
105; This function fills a block of memory with a particular value.
106; The function receives address of the memory, the length of the memory, and
107; the fill value as parameters on the stack.
108; The function does not return a value.
109
110public _ddmemfill
111_ddmemfill proc near
112
113DEST2_LOW equ [bp+4]
114DEST2_HIGH equ [bp+6]
115BUF2_LEN equ [bp+8]
116VALUE2 equ [bp+0ah]
117
118 ; point to parameters and local variables
119 push bp
120 mov bp,sp
121
122 ; save registers
123 push bx
124 push cx
125 push es
126 push di
127
128 ; store number of bytes to transfer and calculate number of double words
129 ; and set of transfer value
130 mov bx,BUF2_LEN
131 mov cx,bx
132 shr cx,2
133
134 ; set size in bytes of object to be allocated
135 mov es,DEST2_HIGH
136 mov di,DEST2_LOW
137
138 ; set up value
139 mov ax,VALUE2
140 shl eax,010h
141 mov ax,VALUE2
142
143 ; set up transfer direction
144 cld
145
146 ; do the transfer
147 rep stosd
148
149 ; transfer number of odd bytes
150 mov cx,bx
151 and cx,03h
152 rep stosb
153
154 ;set up return value and restore registers
155 pop di
156 pop es
157 pop cx
158 pop bx
159 pop bp
160
161 ;done
162 ret
163_ddmemfill endp
164
165_TEXT ENDS
166
167 end
Note: See TracBrowser for help on using the repository browser.