diff --git a/stdlib.asm b/stdlib.asm index 91f94ba..d3a5e26 100644 --- a/stdlib.asm +++ b/stdlib.asm @@ -70,6 +70,42 @@ lb1 tay return A rtl end +**************************************************************** +* +* void *aligned_alloc(size_t alignment, size_t size) +* +* Allocate memory with specified alignment. +* +* Inputs: +* alignment - alignment to use (only value allowed is 1) +* size - bytes of memory to allocate +* +* Outputs: +* Returns pointer to allocated memory, or NULL on error. +* +**************************************************************** +* +aligned_alloc start + csubroutine (4:alignment,4:size),0 + + lda alignment check that alignment==1 + dec a + ora alignment+2 + beq good + stz size return NULL on error + stz size+2 + lda #EINVAL + sta >errno + bra ret + +good ph4