source: xtideuniversalbios/trunk/Assembly_Library/Src/Util/Memory.asm@ 45

Last change on this file since 45 was 41, checked in by Tomi Tilli, 14 years ago

Initial commit for Assembly Library.

File size: 3.7 KB
RevLine 
[41]1; File name : Memory.asm
2; Project name : Assembly Library
3; Created date : 14.7.2010
4; Last update : 15.9.2010
5; Author : Tomi Tilli
6; Description : Functions for memory access.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; Memory_ZeroDSSIbyWordsInCX
13; Parameters
14; CX: Number of words to zero
15; DS:SI: Ptr to buffer to zero
16; Returns:
17; Nothing
18; Corrupts registers:
19; AX
20;--------------------------------------------------------------------
21ALIGN JUMP_ALIGN
22Memory_ZeroDSSIbyWordsInCX:
23 call Memory_ExchangeDSSIwithESDI
24 call Memory_ZeroESDIbyWordsInCX
25 jmp SHORT Memory_ExchangeDSSIwithESDI
26
27;--------------------------------------------------------------------
28; Memory_ZeroSSBPbyWordsInCX
29; Parameters
30; CX: Number of words to zero
31; SS:BP: Ptr to buffer to zero
32; Returns:
33; Nothing
34; Corrupts registers:
35; Nothing
36;--------------------------------------------------------------------
37ALIGN JUMP_ALIGN
38Memory_ZeroSSBPbyWordsInCX:
39 push es
40 push di
41 push ax
42
43 push ss
44 pop es
45 mov di, bp
46 call Memory_ZeroESDIbyWordsInCX
47
48 pop ax
49 pop di
50 pop es
51 ret
52
53;--------------------------------------------------------------------
54; Memory_ZeroESDIbyWordsInCX
55; Parameters
56; CX: Number of words to zero
57; ES:DI: Ptr to buffer to zero
58; Returns:
59; Nothing
60; Corrupts registers:
61; AX
62;--------------------------------------------------------------------
63ALIGN JUMP_ALIGN
64Memory_ZeroESDIbyWordsInCX:
65 xor ax, ax
66 ; Fall to Memory_FillESDIwithAXbyCXtimes
67
68;--------------------------------------------------------------------
69; Memory_FillESDIwithAXbyCXtimes
70; Parameters
71; AX: Word to use to fill buffer
72; CX: Number of words to fill
73; ES:DI: Ptr to buffer to fill
74; Returns:
75; Nothing
76; Corrupts registers:
77; Nothing
78;--------------------------------------------------------------------
79ALIGN JUMP_ALIGN
80Memory_FillESDIwithAXbyCXtimes:
81 cld
82 push di
83 push cx
84 rep stosw
85 pop cx
86 pop di
87 ret
88
89
90;--------------------------------------------------------------------
91; Memory_ExchangeDSSIwithESDI
92; Parameters
93; Nothing
94; Returns:
95; DS:SI and ES:DI are exchanged.
96; Corrupts registers:
97; Nothing
98;--------------------------------------------------------------------
99ALIGN JUMP_ALIGN
100Memory_ExchangeDSSIwithESDI:
101 xchg si, di
102 push ds
103 push es
104 pop ds
105 pop es
106 ret
107
108
109;--------------------------------------------------------------------
110; Memory_CopySSBPtoDSSI
111; Memory_CopySSBPtoESDI
112; Parameters
113; Nothing
114; Returns:
115; DS:SI: Same as SS:BP
116; Corrupts registers:
117; Nothing
118;--------------------------------------------------------------------
119ALIGN JUMP_ALIGN
120Memory_CopySSBPtoDSSI:
121 push ss
122 pop ds
123 mov si, bp
124 ret
125
126ALIGN JUMP_ALIGN
127Memory_CopySSBPtoESDI:
128 push ss
129 pop es
130 mov di, bp
131 ret
132
133
134;--------------------------------------------------------------------
135; Memory_SetZFifNullPointerInDSSI
136; Parameters
137; DS:SI: Far pointer
138; Returns:
139; ZF: Set if NULL pointer in DS:SI
140; Corrupts registers:
141; Nothing
142;--------------------------------------------------------------------
143ALIGN JUMP_ALIGN
144Memory_SetZFifNullPointerInDSSI:
145 push ax
146 mov ax, ds
147 or ax, si
148 pop ax
149 ret
150
151
152;--------------------------------------------------------------------
153; Memory_ReserveCXbytesFromStackToDSSI
154; Parameters
155; CX: Number of bytes to reserve
156; Returns:
157; DS:SI: Ptr to reserved buffer
158; Corrupts registers:
159; AX
160;--------------------------------------------------------------------
161ALIGN JUMP_ALIGN
162Memory_ReserveCXbytesFromStackToDSSI:
163 pop ax
164 push ss
165 pop ds
166 sub sp, cx
167 mov si, sp
168 jmp ax
Note: See TracBrowser for help on using the repository browser.