![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Mar 2006
Posts: 3
Rep Power: 0
![]() |
C / Assembly HELP
I am new to the assembly world i tried to combined the C and assembly code below.
. How do i run (compile both) and how do i access an array if sent as parameter to the assemly part. Thanks #include <stdio.h> extern int add_num(int num1, int num2); int main() { printf("Sum: %d\n" ,add_num(22, 33)); return 0; } /*Assembly part*/ global add_num add_num: push ebp ; save ebp register mov ebp, esp ; get current stack pointer push ebx ; save ebx register mov ebx, [ebp + 8] ; get second parameter mov eax, [ebp + 12] ; get first parameter add eax, ebx ; add numbers,store sum in eax, return value pop ebx ; restore ebx pop ebp ; restore ebp ret ; return to caller /*Make file*/ main :addNum gcc -o main caller.c addNum.o addNum :addNum.asm nasm -felf -o addNum.o addNum.asm |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Please read the forum's rules/FAQ and the "How to Post a Question" thread at the top of the C forum.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|