Solved

linking Turbo C and 8086 assembly

Posted on 2002-05-13
3
896 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
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Patching a Windows EXE 23 752
c code optimization 6 479
assembly flow 3 627
gcc error: -mpreferred-stack-boundary=2 is not between 4 and 12 7 1,900
If you are looking at this article, you have most likely been hit by some version of ransomware and are trying to find out if there is anything you can do, or what way you should react - READ ON!
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

856 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