flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Tyler 13 Sep 2010, 04:36
You can't. You have to input the size by hand.
|
|||
![]() |
|
LocoDelAssembly 13 Sep 2010, 05:00
When allocating, you could request 4 more bytes for the array. Then, before storing the pointer somewhere, you store the calculated size in the first four bytes and then you store the pointer but adding four first (optional step, but recommended so you don't have to worry about it when addressing individual cells).
If alignment is a concern (e.g. you'll use instructions that accesses more than 4 bytes at once), you may allocate more extra bytes instead of just 4 and use the rest for padding. Example: Code: struc Array { .length dd ? .base: } virtual at -4 Array Array end virtual allocateArray:; EAX = number of (32-bit) floats. push eax invoke LocalAlloc, LMEM_FIXED, addr eax*4 + 4 pop dword [eax] add eax, 4 ret freeArray:; EAX = pointer to array invoke LocalFree, addr eax - 4 ret ; Usage example mov eax, 10 call allocateArray mov ebx, eax mov ecx, [ebx + Array.length] ; Equivalent to "mov ecx, [ebx - 4]" fld dword [ebx+4*2] ; Load 3rd element into FPU mov eax, ebx call freeArray |
|||
![]() |
|
edfed 13 Sep 2010, 12:03
to know the size of the array, you first need to read the text file, when converting each string in a value, you will increment a counter. ones you find the "endoftext", or "null" byte, it means that there are no more numbers, and then, the end of the array.
the counter will hold the size of the array. and is determined during the convertion of the text file in an array of datas. |
|||
![]() |
|
ctl3d32 14 Sep 2010, 03:05
Thanks LocoDelAssembly!
Exactly what i needed! |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.