inital code for align_up function

This commit is contained in:
2025-09-05 08:27:56 -04:00
parent f5e4927d70
commit 935427509a

View File

@@ -38,10 +38,28 @@ arena_init:
ret
; size_t align_up(size_t x, size_t a)
; eax, ebx. ecx are all clobbered
arena_align_up:
__CDECL16_ENTRY
.func:
; align the mark to the nearest specified alignment
; align x up to the nearest specified alignment (a)
; (x + (a-1)) & ~(a-1)
mov eax, [bp + 4] ; x
mov ebx, [bp + 6] ; a - 1
sub ebx, 1
mov ecx, eax
add ecx, ebx ; x + (a+1)
not ebx
and ecx, ebx ; ecx contains the result
xor eax, eax
xor ebx, ebx
mov eax, ecx ; return result in eax
xor ecx, ecx
.endp:
__CDECL16_EXIT
ret