Если вас устроит пример для Windows, посмотрите следующую программу в EuroAssembler. Он создает 3128 байт длиной AllocArray.exe , который зарезервирует и инициализирует запрошенный размер в разделе BSS.
AllocArray PROGRAM Format=PE, IconFile=, Entry=Main:
INCLUDE winapi.htm, cpuext32.htm
%MaxPossibleLength %SETA 1_000_000 ; Specify the maximal acceptable allocation here.
[.text]
Main: StdOutput ="Enter the size of the array (1..%MaxPossibleLength): "
StdInput EnterredLength ; Let the user to set array length.
LodD EnterredLength ; Convert the enterred decimal number to integer in EAX.
CMP EAX,%MaxPossibleLength
JA Main:
MOV [LengthOfTheArray],EAX
StoD AllocatedLength ; Convert the integer EAX to decimal.
XOR EAX,EAX
STOSB ; Zero-terminate the decimal number.
MOV EDI,TheArray:
MOV ECX,[LengthOfTheArray]
MOV EAX,0x5A5A5A5A
REP STOSD ; Initialize the array with 5A.
StdOutput ="The array of ", AllocatedLength, =" DWORDs is now allocated statically."
TerminateProgram
[.bss]
EnterredLength: DB 16 * BYTE
AllocatedLength: DB 16 * BYTE
LengthOfTheArray: DD DWORD
TheArray: DD %MaxPossibleLength * DWORD
ENDPROGRAM AllocArray