Subversion Repositories Kolibri OS

Rev

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