Subversion Repositories Kolibri OS

Rev

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