Subversion Repositories Kolibri OS

Rev

Rev 6021 | Rev 7160 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5598 pavelyakov 1
#ifndef INCLUDE_MEM_H
2
#define INCLUDE_MEM_H
3107 leency 3
 
5606 pavelyakov 4
#ifndef INCLUDE_KOLIBRI_H
5
#include "../lib/kolibri.h"
6
#endif
7
 
3107 leency 8
dword mem_init()
3067 leency 9
{
5598 pavelyakov 10
	$push    ebx
6021 leency 11
	$mov     eax, 68
12
	$mov     ebx, 11
13
	$int     0x40
14
 
15
	$pop     ebx
16
	return  EAX;
3067 leency 17
}
18
 
3107 leency 19
dword malloc(dword size)
3067 leency 20
{
6021 leency 21
	$push    ebx
22
	$push    ecx
23
 
24
	$mov     eax, 68
25
	$mov     ebx, 12
26
	$mov     ecx, size
27
	$int     0x40
28
 
29
	$pop     ecx
30
	$pop     ebx
31
	return  EAX;
3067 leency 32
}
33
 
3107 leency 34
stdcall dword realloc(dword mptr, size)
3067 leency 35
{
6021 leency 36
	$push    ebx
37
	$push    ecx
38
	$push    edx
3067 leency 39
 
6021 leency 40
	$mov     eax, 68
41
	$mov     ebx, 20
42
	$mov     ecx, size
43
	$mov     edx, mptr
44
	$int     0x40
45
 
46
	$pop     edx
47
	$pop     ecx
48
	$pop     ebx
49
	return   EAX;
3067 leency 50
}
51
 
3107 leency 52
dword free(dword mptr)
3067 leency 53
{
6021 leency 54
	$push    eax
55
	$push    ebx
56
	$push    ecx
57
 
58
	$mov     eax, 68
59
	$mov     ebx, 13
60
	$mov     ecx, mptr
61
	$test    ecx, ecx
62
	$jz      end0
63
	$int     0x40
3067 leency 64
   @end0:
6021 leency 65
	$pop     ecx
66
	$pop     ebx
67
	$pop     eax
68
	return 0;
3067 leency 69
}
70
 
3107 leency 71
inline fastcall memmov( EDI, ESI, ECX)
3067 leency 72
{
73
  asm {
74
    MOV EAX, ECX
75
    CMP EDI, ESI
76
    JG L1
77
    JE L2
78
    SAR ECX, 2
79
    JS L2
80
    REP MOVSD
81
    MOV ECX, EAX
82
    AND ECX, 3
83
    REP MOVSB
84
    JMP SHORT L2
85
L1: LEA ESI, DSDWORD[ ESI+ECX-4]
86
    LEA EDI, DSDWORD[ EDI+ECX-4]
87
    SAR ECX, 2
88
    JS L2
89
    STD
90
    REP MOVSD
91
    MOV ECX, EAX
92
    AND ECX, 3
93
    ADD ESI, 3
94
    ADD EDI, 3
95
    REP MOVSB
96
    CLD
97
L2:
98
  }
99
}
100
 
3128 leency 101
 
102
 
3107 leency 103
#define mem_Alloc malloc
104
#define mem_ReAlloc realloc
105
#define mem_Free free
106
#define mem_Init mem_init
3067 leency 107
 
5598 pavelyakov 108
#endif