Subversion Repositories Kolibri OS

Rev

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