asm/include/asm/tools.inc
author Markus Bröker <mbroeker@largo.dyndns.tv>
Thu, 16 Apr 2009 12:49:13 +0200
changeset 58 9609c54a54d3
parent 9 c3fecc82ade6
child 166 ecd6492274ad
permissions -rw-r--r--
myprintf.c added - replaces varargs.c 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