diff --git a/programs/cmm/experimental/allocation/compile.bat b/programs/cmm/experimental/allocation/compile.bat new file mode 100644 index 0000000000..65245ae83a --- /dev/null +++ b/programs/cmm/experimental/allocation/compile.bat @@ -0,0 +1,8 @@ +@del mallocFreeRealloc.kex +@c-- mallocFreeRealloc.c +rem @kpack Eolite.com +@rename mallocFreeRealloc.com mallocFreeRealloc.kex + +@del warning.txt +@del lang.h-- +@pause \ No newline at end of file diff --git a/programs/cmm/experimental/allocation/mallocFreeRealloc.c b/programs/cmm/experimental/allocation/mallocFreeRealloc.c new file mode 100644 index 0000000000..a59b207c28 --- /dev/null +++ b/programs/cmm/experimental/allocation/mallocFreeRealloc.c @@ -0,0 +1,176 @@ +#pragma option OST +#pragma option ON +#pragma option cri- +#pragma option -CPA +#initallvar 0 +#jumptomain FALSE + +#startaddress 0x0000 + +#code32 TRUE + +char os_name[8] = {'M','E','N','U','E','T','0','1'}; +dword os_version = 0x00000001; +dword start_addr = #main; +dword final_addr = #______STOP______+32; +dword alloc_mem = 20000; +dword x86esp_reg = 20000; +dword I_Param = #param; +dword I_Path = #program_path; +char param[4096] ={0}; +char program_path[4096] = {0}; + + +:dword mallocSystem(dword size) +{ + $push ebx + $push ecx + + $mov eax, 68 + $mov ebx, 12 + $mov ecx, size + $int 0x40 + + $pop ecx + $pop ebx + return EAX; +} + +:dword offsetAllocData = 0; +:dword malloc(dword size) +{ + dword array = 0; + dword orderSize = 1; + dword order = 0; + dword stackAlloc = 0; + dword stackKey = 0; + dword result = 0; + size+=4; + IF(!offsetAllocData) offsetAllocData = mallocSystem(4*32); + + WHILE(orderSize