Interfacing ASM with c

How to Interface C graphics font such as triplex.chr / gothic.chr etc ., in to my  ASM program and print text in different fonts using graphics interrupts
(Without writing the new char matrix , I  should make use of the already designed  font available in C as stated above)

Please mail me to
cs19721@maurya.rect.ernet.in

if possible
LVL 3
pambooAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
SlartiConnect With a Mentor Commented:
There are several ways to incorporate Assembly and C in the same executable. I will describe two, and you can choose whatever uyou prefer.

The simplest method is to create a standard C file with inline assembler commands. In Borland C (which is what I assume you are using), and also in other compilers, the way this is done is as follows:

int my_func()
{
asm {
  mov ax,0
  ; more assembly commands
}
/* continue with C commands */
return 0;
}

In this way you can create large assembly programs within your C programs. The main problem with this approach is that the assembler itself (what converts your assembly code into machine code) is not very friendly in Borland C and doesn't always give informative error messages when you make mistakes, so perhaps you would want to create code in your assembler and then paste it into Borland C.

The second approach is to create an assembler object file and add it to your C project. Your assembler should create an OBJ file when you assemble your code. This file contains unlinked machine code which can be linked together with code from C. To do this, add the OBJ file to the C project. In addition, you will need to create a hedaer (.H) file in C which contains a list of all functions you want to be able to import from the assembly code to the C code. These prototypes should appear with the keyword "extern", e.g.
extern int assembly_func(int a);
This approach is a little more tricky since your are merging between two different compilers, and you will probably need some level of tweaking before you get it to work.

Good luck!
-- Slarti
0
All Courses

From novice to tech pro — start learning today.