I am currently going through a book. It has C programs that call Assembly routines. I would like to type in some of the programs to see them work.
The C programs are in .c files and the Assembly routines are in .asm files.
How do I create a project in Visual Studio that will compile and assemble and link these files into a program that I can run?
I have access to Visula Studio Versions: 6, 2005, 2010
Sample c file:
Code:
#include <stdio.h>
int first=1, second=2, third=0; // these are the integers with
// whch we want to work.
void main(void)
{
printf("\nBefore adding third =%d",third);
Add_Ext(); // this call the assembly
// program that will add
// externals.
printf("\nAfter adding third = %d",third);
} // end main
Sample asm file:
Code:
.MODEL MEDIUM ; This tells the procedure to use the
; MEDIUM memory model.
EXTRN first:WORD, second:WORD, third:WORD
.CODE ; This is the beginning of the code segment.
_Add_Ext PROC FAR ; The procedure is type FAR.
mov AX, first ; This moves the first number into the
; accumulator.
add AX, second ; This adds the second number to the
; accumulator.
mov third, AX ; This stores the result back into
; third.
_Add_Ext ENDP ; The procedure ends here.
END ; This is the end of the code segment.