asm/include/asm/tools.inc
author Markus Bröker<broeker.markus@googlemail.com>
Sun, 10 Feb 2019 13:17:01 +0100
changeset 173 374a86886bc5
parent 166 ecd6492274ad
permissions -rw-r--r--
LAST-DIGIT-BUG: INCREMENT before LF

;;
;; test/demos/asm/include/asm/tools.inc
;; Copyright (C) 2008 Markus Broeker
;;

extern printf

reg_info:
	enter 0, 0				;; Do i need to reserve space or not?
	
	push DWORD edx
	push DWORD ecx
	push DWORD ebx
	push DWORD eax
	push reg_format
	
	call printf				;; printf modifies eax
	mov eax, [esp+4]			;; restore eax
	leave
	ret

stack_info:
	enter 0, 0				;; Do i need to reserve space or not?
	push eax				;; save eax
	
	push DWORD edi
	push DWORD esi
	push DWORD esp
	push DWORD ebp
	push st_format
	
	call printf				;; printf modifies eax
	add esp, 20				;; move sp 5 dws forward
	pop eax					;; restore eax
	leave
	ret

stack_trace:
	enter 0,0
	push eax
	
	push DWORD [EBP+20]
	push DWORD [EBP+16]
	
	push DWORD [EBP+12]
	push DWORD [EBP+8]

	push DWORD [EBP+4]
	push DWORD [EBP+0]

	push DWORD [EBP-4]
	push DWORD [EBP-8]

	push DWORD [EBP-12]
	push DWORD [EBP-16]
	push DWORD [EBP-20]

	push trace_fmt

	call printf

	add esp, 48
	pop eax
	leave
	ret