--------
#include <stdio.h>
main() {
int num1 = 0;
int num2 = 0;
int sum = 0;
printf("Enter first number:");
scanf("%d", &num1);
printf("Enter second number:");
scanf("%d", &num2);
mysum();
printf("Answer is %d", sum);
}
--------This is the program containing mysum()
int mysum()
{
}
----------THis is the assembly code of the main program
.file "mp.c" .def ___main; .scl 2; .type 32; .endef .section .rdata,"dr" LC0: .ascii "Enter first number:\0" LC1: .ascii "%d\0" LC2: .ascii "Enter second number:\0" LC3: .ascii "Answer is %d\0" .text .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl %esp, %ebp subl $24, %esp andl $-16, %esp movl $0, %eax addl $15, %eax addl $15, %eax shrl $4, %eax sall $4, %eax movl %eax, -16(%ebp) movl -16(%ebp), %eax call __alloca call ___main movl $0, -4(%ebp) movl $0, -8(%ebp) movl $0, -12(%ebp) movl $LC0, (%esp) call _printf leal -4(%ebp), %eax movl %eax, 4(%esp) movl $LC1, (%esp) call _scanf movl $LC2, (%esp) call _printf leal -8(%ebp), %eax movl %eax, 4(%esp) movl $LC1, (%esp) call _scanf call _mysum movl -12(%ebp), %eax movl %eax, 4(%esp) movl $LC3, (%esp) call _printf leave ret .def _mysum; .scl 2; .type 32; .endef .def _scanf; .scl 2; .type 32; .endef .def _printf; .scl 2; .type 32; .endef-------
And this one if the asm code of mysum()
.file "mysum.c" .text .globl _mysum .def _mysum; .scl 2; .type 32; .endef _mysum: pushl %ebp movl %esp, %ebp popl %ebp ret--------
How do i modify the last code (_mysum) in order to compute for the sum in the main program and assign its value?
Edited by WingedPanther, 11 October 2008 - 01:59 PM.
add code tags (the # button)


Sign In
Create Account

Back to top









