-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ec9f62
commit b377245
Showing
4 changed files
with
208 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
%include "src/huffman/bubble_sort.asm" | ||
%include "src/huffman/set_bits_r.asm" | ||
%include "src/huffman/construct_tree.asm" | ||
%include "src/huffman/print_structs.asm" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
; struct CNode | ||
; { | ||
; unsigned m_Bits; | ||
; unsigned m_NumBits; | ||
; | ||
; unsigned short m_aLeafs[2]; | ||
; | ||
; unsigned char m_Symbol; | ||
; } | ||
|
||
; HUFF_CNODE_BITS_OFFSET equ 0 | ||
; HUFF_CNODE_NUM_BITS_OFFSET equ 4 | ||
; HUFF_CNODE_LEAF_0_OFFSET equ 8 | ||
; HUFF_CNODE_LEAF_1_OFFSET equ 10 | ||
; HUFF_CNODE_SYMBOL_OFFSET equ 12 | ||
; HUFF_CNODE_SIZE equ 13 | ||
|
||
_huff_print_field_symbol: | ||
push rax | ||
push rbp | ||
mov rbp, rsp | ||
sub rsp, 24 | ||
mov dword [rbp-24], 'Symb' | ||
mov dword [rbp-20], 'ol: ' | ||
mov byte [rbp-16], 0 | ||
lea rax, [rbp-24] | ||
print_c_str rax | ||
mov rsp, rbp | ||
pop rbp | ||
pop rax | ||
ret | ||
|
||
_huff_print_field_leafs: | ||
push rax | ||
push rbp | ||
mov rbp, rsp | ||
sub rsp, 24 | ||
mov dword [rbp-24], 'Leaf' | ||
mov word [rbp-20], 's:' | ||
mov word [rbp-18], 0x0020 | ||
lea rax, [rbp-24] | ||
print_c_str rax | ||
mov rsp, rbp | ||
pop rbp | ||
pop rax | ||
ret | ||
|
||
_huff_print_field_num_bits: | ||
push rax | ||
push rbp | ||
mov rbp, rsp | ||
sub rsp, 24 | ||
mov dword [rbp-24], 'NumB' | ||
mov dword [rbp-20], 'its:' | ||
mov byte [rbp-16], ' ' | ||
mov byte [rbp-15], 0 | ||
lea rax, [rbp-24] | ||
print_c_str rax | ||
mov rsp, rbp | ||
pop rbp | ||
pop rax | ||
ret | ||
|
||
_huff_print_field_bits: | ||
push rax | ||
push rbp | ||
mov rbp, rsp | ||
sub rsp, 20 | ||
mov dword [rbp-20], 'bits' | ||
mov word [rbp-16], ': ' | ||
mov byte [rbp-14], 0 | ||
lea rax, [rbp-20] | ||
print_c_str rax | ||
mov rsp, rbp | ||
pop rbp | ||
pop rax | ||
ret | ||
|
||
huff_print_struct_cnode: | ||
; huff_print_struct_cnode [rax] | ||
; rax = pointer to cnode struct | ||
push_registers | ||
; pointer to struct | ||
mov rsi, rax | ||
|
||
call print_open_curly | ||
|
||
call _huff_print_field_bits | ||
mov rax, [rsi+HUFF_CNODE_BITS_OFFSET] | ||
call print_int32 | ||
call print_comma | ||
call print_space | ||
|
||
call _huff_print_field_num_bits | ||
mov rax, [rsi+HUFF_CNODE_NUM_BITS_OFFSET] | ||
call print_int32 | ||
call print_comma | ||
call print_space | ||
|
||
call _huff_print_field_leafs | ||
call print_open_bracket | ||
mov rax, [rsi+HUFF_CNODE_LEAF_0_OFFSET] | ||
call print_int32 | ||
call print_comma | ||
call print_space | ||
mov rax, [rsi+HUFF_CNODE_LEAF_1_OFFSET] | ||
call print_int32 | ||
call print_close_bracket | ||
call print_comma | ||
call print_space | ||
|
||
call _huff_print_field_symbol | ||
mov rax, [rsi+HUFF_CNODE_SYMBOL_OFFSET] | ||
call print_int32 | ||
|
||
call print_close_curly | ||
|
||
pop_registers | ||
ret | ||
|
||
huff_print_arr_nodes: | ||
; print_struct_array [array buffer] [element_print_callback] [element size] [array size] | ||
print_struct_array huff_nodes, huff_print_struct_cnode, HUFF_CNODE_SIZE, HUFFMAN_MAX_NODES | ||
ret | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters