Crat an assmbly program (asm_program.asm) which calls a C function (c_function.c
ID: 3887301 • Letter: C
Question
Crat an assmbly program (asm_program.asm) which calls a C function (c_function.c).
Your C function should tak on argumnt [a pointr to a charactr string] and print it (g. printstring(const char* mystring)).
Your assmbly program should call th C function to print out a haiku (classic or slf-authord) of your choosing, and th author's nam.
Your haiku should b dclard and dfind in asm_program.asm [NOT in c_function.c].
Compil and link your cod to mak an xcutabl (asm_program).
Crat a C program (c_program.c) which calls an assmbly function (asm_function.asm).
Your assmbly function should tak on argumnt [a pointr to a charactr string] and print it.
Your C program should call th assmbly function to print out a haiku (classic or slf-authord) of your choosing, and th author's nam.
Your haiku should b dclard and dfind in c_program.c [NOT in asm_function.asm].
Compil and link your cod to mak an xcutabl (c_program).
Explanation / Answer
/ *Call Assembly function from C function* /
#include <stdio.h>
extern string asm_function(const char * mystring);
string c_function()
{ const char * mystring = "Type you string to print";
printf(" %s", const char * mystring);
asm_function (const char * mystring);
printf(" %s, const char * mystring);
return string;
}
Assembly
AREA sprint, CODE, READONLY
EXPORT asm_function
asm_function
// Do operation
BNE asm_function
BX lr ; Return.
END
----------------------------------------------
/ *Call C function from Assembly function*
String c_fuction(const char * mystring) {
/*Body section*/
}