asm/include/asm/tools.inc
author Markus Bröker <mbroeker@largo.dyndns.tv>
Mon, 09 Sep 2013 15:51:32 +0200
changeset 166 ecd6492274ad
parent 9 c3fecc82ade6
permissions -rw-r--r--
Test committer: Markus Bröker <mbroeker@largo.homelinux.org>

;;
;; 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