Subversion Repositories Kolibri OS

Rev

Rev 5598 | Rev 5676 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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