Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8719313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:45:52+00:00 2026-06-13T06:45:52+00:00

I am practicing C and assembly language mix programming using GCC. And this error

  • 0

I am practicing C and assembly language mix programming using GCC. And this error occered:

1 deng@ubuntu:~/workspace/leos_test$ make
2 ld -o deng c.o asm.o
3 ld: warning: cannot find entry symbol _start; defaulting to 0000000008048074
4 c.o: In function `main':
5 c_and_asm.c:(.text+0x19): undefined reference to `add'
6 c_and_asm.c:(.text+0x2e): undefined reference to `printf'
7 make: *** [deng] Error 1

This is the C code:

1 #include<stdio.h>
2 void extern add(int * i);
3 void main(){
4    int i=1;
5    add(&i);
6    printf("%d ",i);
7}

Here is the assembly language code:

1 .globl _add
2 _add:
3 push %bp;
4 mov %sp,%bp;
5 mov 0x4(%bp),%eax;
6 incw (%eax);
7 popw %bp;
8 ret

This is the makefile:

1 deng: c.o asm.o
    2 ld -o deng c.o asm.o
3 c.o:
    4 gcc -o c.o -c c_and_asm.c
5 asm.o:
    6 as -o asm.o c_asm.asm

Any suggestion will be appreciated 🙂 .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:45:54+00:00Added an answer on June 13, 2026 at 6:45 am

    Change your c_asm.asm file to this:

    .section .text
    .global add
    .type add,@function
    add:
    push %bp;
    mov %sp,%bp;
    mov 0x4(%bp),%eax;
    incw (%eax);
    popw %bp;
    ret
    

    include in your ld this parameter -lc and better change the file extension to .s

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

practicing programming with MyProgrammingLab and getting following compile error: ApartmentBuilding.java:4: error: expected its also
I'm practicing programming in Assembly, making code C. I don't understand the conversion of
Alright I am practicing using cURL to login to different webservices. For this pariticular
i'm practicing with this stored procedure on a MYSQL database to make payments between
I'm practicing some XSL and using this XML document as a simple example: <?xml
I'm practicing using mulitple files and header files etc. So I have this project
I'm experimenting with ARM assembly language, during this I often use inline assembly blocks
I am practicing to write a bootstrap using assembly (in AT&T syntax, and gnu/gas).
Started practicing with XML and C# and I have an error message of There
I am practicing at getting consistent with my error handling, and I keep hoping

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.