Problem calling Assembly procedure from C
Posted: Tue Feb 21, 2012 8:16 pm
Background:
I have compiled the cross-compiler in CYGWIN and it functions.
In REAL-MODE assembly I can setup the GDT and get into PMODE with the interupts disabled (cli).
Then I write confirmation out to video twice in assembly calling an assembly procedure "ax_vid_32".
In between the video ouputs I can call an externally defined c "main", which is an empty function:
So,I successfully return from c to the second video output.
Both video outputs are visible and the program hangs with a "hang: jmp hang"
There are three files:
1. Second.asm (sets up GDT, switches to PMODE outputs to video via "ax_vid_32" in UTIL32.ASM and calls the "main" in kernel.c
2. kernel.c (which calls the video out routine "ax_vid_32" in UTIL32.ASM)
3. UTIL32.ASM (containing "ax_vid_32")
These won't link properly with this:
I get undefined references. So I partially link SECOND.o and kernel.o with the "-r" option and the link that result to UTIL32.o with no problems
Problem:
I want to call the video output procedure in assembly to confirm I can do something in the main function
that calls assembly procedures. But the pc (virtual machine in VMware) crashes (triple-fault?) after the first video output.
The modified "main" looks like this:
I realize I may need to supply more information for a someone to understand what I am doing wrong.
If you would be so kind please let me know what else to provide.
This is my first use of the forum.
Jon
I have compiled the cross-compiler in CYGWIN and it functions.
In REAL-MODE assembly I can setup the GDT and get into PMODE with the interupts disabled (cli).
Then I write confirmation out to video twice in assembly calling an assembly procedure "ax_vid_32".
In between the video ouputs I can call an externally defined c "main", which is an empty function:
Code: Select all
int main()
{
return 0;
}
Both video outputs are visible and the program hangs with a "hang: jmp hang"
There are three files:
1. Second.asm (sets up GDT, switches to PMODE outputs to video via "ax_vid_32" in UTIL32.ASM and calls the "main" in kernel.c
2. kernel.c (which calls the video out routine "ax_vid_32" in UTIL32.ASM)
3. UTIL32.ASM (containing "ax_vid_32")
These won't link properly with this:
Code: Select all
i586-elf-ld -T link.ld -o SECOND.BIN SECOND.o kernel.o UTIL32.o
Problem:
I want to call the video output procedure in assembly to confirm I can do something in the main function
that calls assembly procedures. But the pc (virtual machine in VMware) crashes (triple-fault?) after the first video output.
The modified "main" looks like this:
Code: Select all
extern void ax_vid_32();
int main()
{
ax_vid_32();
return 0;
}
If you would be so kind please let me know what else to provide.
This is my first use of the forum.
Jon