|
From: Per W. <pw...@ia...> - 2003-03-10 00:38:23
|
I have no experience with gas, but are you clearing your stack arguments (addl $xx,%esp) correctly. In my eyes, you seem to pop too much data. You should only remove as much data as you have pushed on the stack. One other thing. You might bunch together a lot of calls before finally clearing the stack, i.e. you don't have to remove the arguments between each function call. /Per W On Sun, 9 Mar 2003, Carlos Garc=EDa del Monte wrote: > Well, I'll need to work it out from zero myself (but after learning > NASM). I want only one question I cannot solve, and if it gets assembled > without errors I don't know if it because it is done right or not, in > fact I get run-time errors. > It's about variable declaration and initialization: > > The current code which is assembled but doesn't run is: > > .data > mensaje1: .ascii "Introduzca un n=FAmero\n\0" > mensaje2: .ascii "El doble es: \0" > string: .ascii "%d\n\0" > numer: .long 200 > > .bss > .comm entero, 4 > > > .text > .global _asm_main > .extern _printf > .extern scanf > _asm_main: > enter $0, $0 > pusha > > movl (mensaje1), %eax > push %eax > call _printf > addl $12, %esp > > movl numer, %eax > push %eax > push (string) > call _printf > addl $16, %esp > > push (entero) > push (string) > call _scanf > movl %eax, (entero) > addl $16, %esp > > movl entero, %eax > addl %eax, %eax > movl %eax, %ebx > > movl (mensaje2), %eax > push %eax > call _printf > addl $12, %esp > > movl %ebx, %eax > push %eax > push (string) > call _printf > addl $16, %ebp > > popa > movl $0, %eax > leave > ret > > Can someone make these pieces of code be correctly written? If so many > thanks, if not, thanks anyway. > Have a nice day, all of you. > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Etnus, makers of TotalView, The debugg= er > for complex code. Debugging C/C++ programs can leave you feeling lost and > disoriented. TotalView can help you find your way. Available on major UNI= X > and Linux platforms. Try it free. www.etnus.com > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |