• C

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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SlartiCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.