1 ; returns modified node_ptr
2 ; uint32_t proc_heap(uint64_t *heap, uint32_t heap_size);
4 %include "reg_sizes.asm"
5 %include "heap_macros.asm"
7 %ifidn __OUTPUT_FORMAT__, win64
8 %define heap rcx ; pointer, 64-bit
28 global build_huff_tree
30 %ifidn __OUTPUT_FORMAT__, win64
38 ; REMOVE_MIN64(heap, heap_size, h1);
39 mov h2, [heap + heap_size*8]
41 mov qword [heap + heap_size*8], -1
46 heapify heap, heap_size, i, child, h2, h3, tmp32, tmp2
50 mov [heap + node_ptr*8], h1 %+ w
51 mov [heap + node_ptr*8 - 8], h2 %+ w
57 ; replace_min64(heap, heap_size, h3)
60 heapify heap, heap_size, i, child, h2, h3, tmp32, tmp2
66 mov [heap + node_ptr*8], h1 %+ w
69 %ifidn __OUTPUT_FORMAT__, win64
78 %ifidn __OUTPUT_FORMAT__, win64
83 mov qword [heap + heap_size*8 + 8], -1
88 heapify heap, heap_size, h1, child, h2, h3, tmp32, tmp2
93 %ifidn __OUTPUT_FORMAT__, win64