Question

OK, write a "hello, world!" C program. Keep it simple. On the Linux box, use cc...

OK, write a "hello, world!" C program. Keep it simple.

On the Linux box, use cc to convert the C source to Assembler source.

Suppose nobody's told you how to do that, but some kind soul mentioned the "man" (Unix Programmer's Manual) database. You'll be using the cc command, so what does the database have to say about cc? Find your own answers, this is real-world.

After you have the Assembler Source, see if you can assemble and link it so it runs.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please fidn my code:

#include <stdio.h>

int main() {

printf("Hello, World!\n");

return 0;

}

Use the -S option to cc

cc -S hello.c
This will run the preprocessor over hello.c, perform the initial compilation and then stop before the assembler is run.

By default this will output a file hello.s. The output file can be still be set by using the -o option.


Of course this only works if you have the original source. An alternative if you only have the resultant object file is to use objdump, by setting the --disassemble option (or -d for the abbreviated form).

objdump -S --disassemble hello > hello.dump

→ thirdweek → thirdweek cc -S hello.c → thirdweek cc -S -o hello, s hello.c thirdweek thirdweek thirdweek objdump -S --disass

Add a comment
Know the answer?
Add Answer to:
OK, write a "hello, world!" C program. Keep it simple. On the Linux box, use cc...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please write a BASH Script in LINUX that... 1. is actually executable 2. has a comment...

    Please write a BASH Script in LINUX that... 1. is actually executable 2. has a comment to tell us what you did, why and how. 3. allows a user to enter their name and a number between 1 than 100 (this must be prompted so the user knows what to do) 4. creates a random number between 1 and 100 for you to guess. The command to create a random number is shown below. (if you find a better one...use...

  • Writing Unix Utilities in C (not C++ or C#) my-cat The program my-cat is a simple...

    Writing Unix Utilities in C (not C++ or C#) my-cat The program my-cat is a simple program. Generally, it reads a file as specified by the user and prints its contents. A typical usage is as follows, in which the user wants to see the contents of my-cat.c, and thus types: prompt> ./my-cat my-cat.c #include <stdio.h> ... As shown, my-cat reads the file my-cat.c and prints out its contents. The "./" before the my-cat above is a UNIX thing; it...

  • Assignment Overview In Part 1 of this assignment, you will write a main program and several...

    Assignment Overview In Part 1 of this assignment, you will write a main program and several classes to create and print a small database of baseball player data. The assignment has been split into two parts to encourage you to code your program in an incremental fashion, a technique that will be increasingly important as the semester goes on. Purpose This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of...

  • For a C program hangman game: Create the function int play_game [play_game ( Game *g )]...

    For a C program hangman game: Create the function int play_game [play_game ( Game *g )] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) (Also the link to program files (hangman.h and library file) is below the existing code section. You can use that to check if the code works) What int play_game needs to do mostly involves calling other functions you've already...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT