Upd: function indexArray, add: new example

git-svn-id: svn://kolibrios.org@7881 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pavelyakov 2020-05-07 08:16:59 +00:00
parent da6a4c5b74
commit 40267e753c
2 changed files with 51 additions and 5 deletions

46
programs/cmm/examples/array2.c Executable file
View File

@ -0,0 +1,46 @@
#define MEMSIZE 4096*400
#include "../lib/window.h"
#include "../lib/array.h"
window win1=0;
void main()
{
win1.background = 0xFFFFFF;
win1.left = 200;
win1.top = 200;
win1.caption = "Stress test";
win1.ondraw = #draw_window;
win1.create();
}
void draw_window()
{
dword init = 0;
dword count = 0;
dword position = 0;
dword y = 15;
init = malloc(0x1000);
count = 200000;
while (count)
{
position = indexArray(init, count);
DSDWORD[position] = count*2;
count--;
}
position = indexArray(init, 123);DSDWORD[position] = 0;
position = indexArray(init, 777);DSDWORD[position] = 0;
count = 200000;
while (count)
{
position = indexArray(init, count);
if (DSDWORD[position] != count*2)
{
WriteText(15, y, 0x81, 0xFF0000, itoa(count));
y += 25;
}
count--;
}
}

View File

@ -173,13 +173,13 @@
RETURN array.init(size);
}
dword indexArray(dword address, key)
:dword indexArray(dword address, key)
{
dword offset = key&11b;
dword offset = key&0x1FF;
dword offsetAddress = offset*4+address;
IF (key==offset) RETURN 4*4+offsetAddress;
IF (!DSDWORD[offsetAddress]) DSDWORD[offsetAddress] = malloc(4*4*2);
RETURN indexArray(DSDWORD[offsetAddress], key>>2);
IF (key==offset) RETURN 4*0x200+offsetAddress;
IF (!DSDWORD[offsetAddress]) DSDWORD[offsetAddress] = malloc(0x1000);
RETURN indexArray(DSDWORD[offsetAddress], key>>9);
}
#endif