From the course: Advanced C Programming: Integrating C and Assembly Language

Challenge: Linking modules

- [Instructor] For this challenge, you must link modules. I've written some assembly language basic I/O functions and placed them into the exercise files; output which contains string output functions or routines, and input which contains string input routines. For the output functions, print_strz outputs a null character terminated string, print_string outputs a string of a given length, and newline_out outputs a newline character. Only one input function is available; input which reads text from standard input up to a given number of characters. Details in each source code module explain the entry and exit options for each function. Your task is to write a main module that uses these functions, prompt the user to input their name, output their name in a greetings message, prompt for their mood, and then output a comment on the mood. Here's a sample run of my solution. I'll run the code, and I am Dan and I'm feeling great. There you go. As a review, external functions must be declared at the start of your main module. Use the extern keyword. Ensure that you properly call each function. Details are already written in the supplied modules, so this part of the solution should run rather smoothly. To build the program, first assemble each module. For example, use this command; nasm -f elf64 and the assembly source code file name. Each module must be assembled and an object code .O file created. Link the object modules like this; ld, the linker name, and the list of object code files, main output and input, dash o and the output file name program which is the program file name in this example. This is really the meat of the challenge to ensure that you link different modules to create a single project. To review, write code that prompts for the username, output their name and a greetings, prompt for their mood, output a comment on the mood. This challenge should take about 30 minutes to complete.

Contents