there's usually no need to create a heap
the OS creates one for each process
.DATA?
hHeap HANDLE ?
lpBlock LPVOID ?
dwError DWORD ?
.CODE
what i generally do is, during program initialization....
INVOKE GetProcessHeap
mov hHeap,eax
then, to allocate memory and set an error condition, you might do something like this...
and dwError,0
INVOKE HeapAlloc,hHeap,HEAP_ZERO_MEMORY,1000h
mov lpBlock,eax
.if !eax
INVOKE GetLastError
mov dwError,eax
xor eax,eax
.endif
i don't usually store the error condition like that
if the allocation fails, i either provide some other method (like VirtualAlloc)
or give them a MessageBox that says Insufficient Memory and terminate the program
and, to free the allocated block when done...
mov eax,lpBlock
.if eax
xor ecx,ecx
mov lpBlock,ecx
INVOKE HeapFree,hHeap,ecx,eax
.endif