summaryrefslogtreecommitdiff
path: root/epilogue.snippet.asm
diff options
context:
space:
mode:
Diffstat (limited to 'epilogue.snippet.asm')
-rw-r--r--epilogue.snippet.asm43
1 files changed, 29 insertions, 14 deletions
diff --git a/epilogue.snippet.asm b/epilogue.snippet.asm
index b37d48b..7018fc1 100644
--- a/epilogue.snippet.asm
+++ b/epilogue.snippet.asm
@@ -18,30 +18,35 @@
call _write
%endif
-%ifdef HEATMAP
+%ifdef HEATMAPFNAME
+ lea rdi, [HMfname]
+ lea rsi, [HMfmode]
+ call _fopen
+ cmp rax, 0
+ jz fopenerror
+ mov r13, rax ;file pointer
+
mov ebx, 0 ;loop counter
hmloop:
- lea rdi, [strbuf64] ; snprintf(strbuf64,64,HMformatstr,ebx /*counter*/,r12[rbx])
- mov esi, 64
- lea rdx, [HMformatstr]
- mov ecx, ebx
- mov r8d, dword [r12+4*rbx]
- xor eax, eax
- call _snprintf
-
- mov edi, 2
- lea rsi, [strbuf64]
- mov edx, eax
- call _write
+ mov rdi, r13
+ lea rsi, [HMformatstr]
+ mov edx, ebx
+ mov ecx, dword [r12+4*rbx]
+ call _fprintf
inc ebx
cmp ebx, SOURCE_LENGTH
jl hmloop
+
+ mov rdi, r13
+ call _fclose
%endif
xor eax, eax
mainend:
+ pop r13
+ pop r13
pop r12
pop rbx
mov rsp, rbp
@@ -56,6 +61,12 @@ nomem:
mov eax, 1
jmp mainend
+fopenerror:
+ lea rdi, [fopenstr]
+ call _perror
+ mov eax, 1
+ jmp mainend
+
section .data
sectalign 8
@@ -70,7 +81,11 @@ nomemstr: db "Out of memory!"
maxp: dq 0
%endif
-%ifdef HEATMAP
+%ifdef HEATMAPFNAME
+ fopenstr: db "fopen", 0
+
+ HMfname: db HEATMAPFNAME
+ HMfmode: db "w", 0
HMformatstr: db "%d %d", 10, 0
%endif