/* Allocate memory from the heap. Check that we don't collide with the stack right now (some other routine might later). A watchdog might be used to check if cur_break and the stack pointer meet during runtime.  */
void* sbrk(int incr)
/* Allocate memory from the heap. Check that we don't collide with the stack right now (some other routine might later). A watchdog might be used to check if cur_break and the stack pointer meet during runtime.  */
void* sbrk(int incr)
{
    char *stack_pointer;
    asmv("mov r1, %0" : "=r"(stack_pointer));
    stack_pointer -= STACK_EXTRA;
    if (incr > (stack_pointer - cur_break)) {
        return (void *) - 1;
    }
    void *old_break = cur_break;
    cur_break += incr;
    return old_break;
}