diff options
| -rw-r--r-- | debug.inc | 14 | ||||
| -rw-r--r-- | linked_list.inc | 18 | ||||
| -rw-r--r-- | main.asm | 22 | 
3 files changed, 46 insertions, 8 deletions
@@ -6,6 +6,12 @@  %ifndef DTOS_INC  %include "dtos.inc"  %endif +%ifndef MONAD_INC +%include "monad.inc" +%endif + +	section .data +	m_make	debug_register  	;; TODO: Make print without newlineg  %macro	DEBUG_HERE	0-1	"" @@ -23,4 +29,12 @@  	lea	rax,	[rel %%text]  	call	print_zstring  %endm + +%macro	REGD	0-2	rax,h +	section	.text +	lea	rax,	[%1] +	m_return	rel m_debug_register +	m_bind	data_to_zstring_m%2 +	m_call	print_zstring +%endm  %endif diff --git a/linked_list.inc b/linked_list.inc index 76a3956..4fbb923 100644 --- a/linked_list.inc +++ b/linked_list.inc @@ -15,20 +15,30 @@ dll_prev:	resq	1  dll_value:	resq	1  endstruc -%macro	alloc_lln	0 +%macro	lln_alloc	0  	alloc	LinkedListNode_size +	mov	qword [rax + ll_next],	0  %endmacro -%macro	alloc_dlln	0 +%macro	dlln_alloc	0  	alloc	DoublyLinkedListNode_size +	mov	qword [rax + dll_next],	0  %endmacro -%macro	free_lln	0-1	rax +%macro	lln_free	0-1	rax  	free	%1,	LinkedListNode_size  %endmacro -%macro	free_dlln	0-1	rax +%macro	dlln_free	0-1	rax  	free	%1,	DoublyLinkedListNode_size  %endmacro +%macro	ll_push	2 +	;; %1 = Current Linked List Node +	;; %2 = Value to push (Must fit in a register, larger must be pushed as pointer to the underlying structure) +	lln_alloc +	mov	qword [%1 + ll_next],	rax +	mov	qword [rax + ll_value],	%2 +%endm +  %endif @@ -74,8 +74,8 @@ _main:  	alloc	FBUF_ALLOC_SIZE  	mov	rbx,	rax  	m_call	ffopen,	rel m_test_file -	mov	[rel test_file_filedata + buffer], rbx -	mov	qword [rel test_file_filedata + size], FBUF_ALLOC_SIZE +	mov	[rel test_file_filedata + fd_buffer], rbx +	mov	qword [rel test_file_filedata + fd_size], FBUF_ALLOC_SIZE  	flen	test_file  	push	rax  	m_return	rel m_test_mdots @@ -89,14 +89,28 @@ _main:  	call	ffread  	fclose	test_file -	mov	rax,	[rel test_file_filedata + buffer] +	mov	rax,	[rel test_file_filedata + fd_buffer]  	mov	rcx,	0  	add	rax,	54  	mov	[rax],	rcx -	mov	rax,	[rel test_file_filedata + buffer] +	mov	rax,	[rel test_file_filedata + fd_buffer]  	call	print_zstring  	free	rbx,	FBUF_ALLOC_SIZE +	lln_alloc +	push	rax +	mov	rbx,	rax +	mov	r12,	0xDEADBEEF +	ll_push	rbx,	r12 +	push rax +	mov	rax,	[rax + ll_value] +	REGD	rax +	pop rax +	lln_free +	pop	rax +	lln_free + +  	exit_prog  .error.exit:  | 
