I need help with allocating memory with system calls in homework project. I get a number 'x' from the command line argument and I need to allocating array of 'x' structs which include two fields of dword.
I tried do that using the brk system call but I think that I don't understand it pretty good, this is my try:
mov eax, SYS_BRK ;using brk system call
mov ebx, 0
int 0x80
mov [CORS], eax ;CORS-the array of the structs
mov [initialallocated], eax
mov ecx, [dronesNumber]
shl ecx, 3 ;8 bytes * numberOfDrones
mov eax, SYS_BRK
mov ebx, [CORS]
add ebx, ecx
int 0x80
mov [CORS], eax
mov ecx, dronesNumber
here:
.myLoop:
mov eax, SYS_BRK
mov ebx, 0
int 0x80
mov [CORS + 8*ecx], eax ;segmentation fault here
mov eax, SYS_BRK
mov ebx, [CORS + 4*ecx]
add ebx, ecx
int 0x80
mov [CORS + 4*ecx], eax
loop .myLoop, ecx