aboutsummaryrefslogtreecommitdiff
path: root/debug.inc
blob: f41009607a642f2f6483af70b595cc59187a8963 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
%ifndef DEBUG_INC
%define DEBUG_INC
%ifndef ZSTRING_INC
%include "zstring.inc"
%endif
%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	""
	section .data
	make_zstring	%%head,	"Log: ", __?FILE?__,":"
	make_zstring	%%text,	%1,10

	section .text
	lea	rax,	[rel %%head]
	call	print_zstring
	mov	rax,	__?LINE?__
	call	data_to_zstring_md
	mov	rax,	[rax]
	call	print_zstring
	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

%macro	FLAGD	0-1	h
	pushfq
	pop	rax
	REGD	rax,	%1
%endm
%endif