?
Solved

adding asmbly to c code

Posted on 2003-03-02
5
Medium Priority
?
237 Views
Last Modified: 2010-04-15
hey there, this a lame question but how can i add a block of c code in borland C... i know asm whatever will add on line but how could i add like a block?

also are there any headers i should include for 8086 stuff so i can use my registers and what not


thanks for the help
0
Comment
Question by:tacom8
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
Exceter earned 200 total points
ID: 8053034
>> but how could i add like a block?

Have you tried,

asm
{
}

>> also are there any headers i should include for 8086 stuff so i can use my registers and what not

In borland you can simply say,

union REGS regs;

regs.h.ah = 0x00;

For example, these two functions compile and run under Borland C,

void cls(void)
{
    union REGS regs;
    regs.h.ah=0x06;
    regs.h.al=0x00;
    regs.h.bh=0x07;
    regs.h.ch=0x00;
    regs.h.cl=0x00;
    regs.h.dh=ROWS - 1;
    regs.h.dl=COLS - 1;
    int86(VIDEO,&regs, &regs);
    locate(0,0);
}

void locate(int col, int row)
{
    union REGS regs;
    regs.h.ah=0x02;
    regs.h.bh=0x00;
    regs.h.dh=row;
    regs.h.dl=col;
    int86(VIDEO,&regs,&regs);
}

Exceter
0
 
LVL 8

Expert Comment

by:Exceter
ID: 8053041
Note: I do realize that those are not written directly in assembly language. :-)
0
 
LVL 8

Expert Comment

by:akshayxx
ID: 8054538
here is small example on how do u do it with gnu c compiles gcc
__asm__ is used to make assembly calls

int foo( int a )
{
  int b = 10;

  a = 20;
  __asm__ ("mov %1, %0" : "=r"
   (a) : "r" (b) ); /* a = b */
  return a;
}

This  is simply copying b to a, and the return value is always 10.

and here is a link for inline assembly with gcc
http://www.tldp.org/HOWTO/Assembly-HOWTO/gcc.html
0
 
LVL 8

Expert Comment

by:akshayxx
ID: 8054548
sorry ignore my comments.. as just now i noticed . u want this to be with borland C.. Sorry for bothering u ppl
0
 

Author Comment

by:tacom8
ID: 8054568
hey thanks for the help fellas ill give it a shot later..
but it looks like it should do the trick

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question