I have trouble understanding this part in the module initialisation:
Code: Select all
IF heapLimit = 0 THEN
stackLimit := 0
ELSE
(* Separate heap / stack *)
stackLimit := 010000200H
END;
If the value of 'Heap Limit is set to zero, there's dynamic sharing, else the heap is limited to the value set. With dynamic sharing, the heap can grow up to the current stack pointer at the time of the allocation. The stack can grow down without limitations, even into the heap space. (Without hardware support, it would be performance consuming to keep the stack pointer "in check" upon each procedure call.)
I would have expected that 'stackLimit' be set to 'heapLimit' if 'Heap Limit' is not zero. The constant '010000200H' is not an address within the 32 kB RAM range of my MO STM32F091 (the data range of the STM32F091 is 020000000H to 020008000H).
I am aware that the allocator does not use 'stackLimit', but 'Storage.StackAvailable' will return a wrong value with a non-zero 'Heap Limit' value, given the above assigment of the constant.