Subversion Repositories Kolibri OS

Rev

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