Solved

linking Turbo C and 8086 assembly

Posted on 2002-05-13
3
902 Views
Last Modified: 2010-05-18
i use turbo c 3.0 compiler and turbo assembler.i want to connect or combine 8086 assembly( for low level stuff) and C routines.i could not find good resources of information.can you please help me in finding some.thanks
0
Comment
Question by:vinayak_j
[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
3 Comments
 
LVL 11

Accepted Solution

by:
dimitry earned 50 total points
ID: 7007587
I suggest you to try next thing:
1. In order to create assembler function that you can call
from c:
- Define it in .h file as:
 void cdecl myasmfunc( params );
- And in assembler its header should look like:
 _TEXT     segment byte public 'CODE'
  ;
  ;     void cdecl myasmfunc( params )
  ;
    assume     cs:_TEXT
 _myasmfunc proc     near
    push     bp
    mov     bp,sp
       ...
    ; 16-bit parameter1 - word ptr [bp+4]
    ; 16-bit parameter2 - word ptr [bp+6]
       ...
 _myasmfunc endp

 _TEXT     ends
    public     _myasmfunc
    end

2. To call function from assembler:
- Define it in .h file as:
 void near cdecl mycfunc( params );
- And in assembler its header should look like:
 extrn  _mycfunc : near
  ...
 push  parameter2
 push  parameter1
 call  _mycfunc

Note: You need to pass parameters correctly from and to
your functions. In C convention you need to enter parameters to stack in opposite order.

0
 
LVL 2

Expert Comment

by:jonnin
ID: 7023824
Also, using the turbo assembler, you can make obj files that can be linked.  Make sure the asm routines use C calling conventions or place the push/pop pairs in the C to clean up (see above and articles on this)

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Getting to know the threat landscape in which DDoS has evolved, and making the right choice to get ourselves geared up to defend against  DDoS attacks effectively. Get the necessary preparation works done and focus on Doing the First Things Right.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

623 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