I'm using nasm to assemble a simple program that outputs a character, & that function is declared global inside of the assembly code:
CODE
GLOBAL _line
SECTION .data
msg: db "-"
len: equ $-msg
SECTION .text
_line:
mov edx, len
mov ecx, msg
mov ebx, 1
mov eax, 4
int 0x80
mov ebx, 0
mov eax, 1
int 0x80
It assembles without error (as it's fairly simple) & runs as designed.
So in my c code, I declare the function external that will call from the linked assembly object file :
CODE
#include <stdio.h>
extern void _line(void);
int main(void) {
printf("The following should be the assembly code:\n");
_line();
return 0;
}
When I compile it, I get no errors using
gcc dash o main main.c line.oHowever when I run the file, the
only thing that happens is the assembly code. What am I doing wrong?!
My guess is that somehow the assembly code has the main therefor once it's processing, it's done. So the main from the c code is being ignored.