Solved

linking Turbo C and 8086 assembly

Posted on 2002-05-13
3
895 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASM problem 2 31 346
Binary Bomb/GDB Questions 10 1,904
cmpl in assembly 5 1,342
memory mapped I/O query 6 147
When we purchase storage, we typically are advertised storage of 500GB, 1TB, 2TB and so on. However, when you actually install it into your computer, your 500GB HDD will actually show up as 465GB. Why? It has to do with the way people and computers…
An article on effective troubleshooting
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 …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

772 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