How to Link Assembly with Turbo C 2.0?

Started by vasant, November 02, 2005, 11:24:42 AM

Previous topic - Next topic

vasant

How to Assembly coding for link with Turbo C 2.0?

vasant

[C Code]

#include <stdio.h>
main()
{ char string1[32],string2[32];
  printf("Put string 1:");
  GET_TXT(string1);
  printf("\n");
  printf("Put string2:");
  GET_TXT(string2);
  printf("\n");
}
[ASM Code]
PGROUP  GROUP   PROG
PROG    SEGMENT BYTE PUBLIC 'PROG'
        PUBLIC  GET_TXT,READ_TXT ;FUNCTION TO 'C'
        ASSUME  CS:PGROUP
;
; LINK TO 'C' COMPILER

GET_TXT         PROC NEAR  ; (STRING FROM C) (ARRAY)
                PUSH BP
                MOV BP,SP  ; MOVE STACK POINTER TO BASE POINTER
                MOV SI,[BP+4]
                MOV BX,0
                MOV CX,30
                MOV AH,2
                CMP AL,0DH
                JE  EXIT_
A1:             INT 21H
                MOV [SI+BX],AL
                INC  BX
                LOOP A1
EXIT_:          INC BX
                MOV BYTE PTR [SI+BX],'$'
                POP BP
                RET
GET_TXT         ENDP
;----------------------------
READ_TXT        PROC NEAR
                PUSH BP
                MOV BP,SP
                MOV SI,[BP+4]
                MOV AH,9
                MOV DX,SI
                INT 21H
                POP BP
                RET
READ_TXT        ENDP
;---------------------------------------
PROG            ENDS
                END
;----------------------------------------------------------------------------------------------

[Step Link]
>tlink c+asm
Turbo Link  Version 2.0  Copyright (c) 1987, 1988 Borland Internationa
Undefined symbol '_PRINTF' in module C.C
Undefined symbol '_GET_TXT' in module C.C
Warning: no stack

QUESTION
1 Why "Undefined symbol '_PRINTF' in module C.C" which include from <stdio.h> ?
2.Why "Undefined symbol '_GET_TXT' in module C.C" which link with assembly ?

Gustav

> 2.Why "Undefined symbol '_GET_TXT' in module C.C" which link with assembly ?

your GET_TEXT proc should be:

GET_TXT         PROC NEAR C ; (STRING FROM C) (ARRAY)

> 1 Why "Undefined symbol '_PRINTF' in module C.C" which include from <stdio.h> ?

you must include the C runtime modules:

tlink c0t.obj+c+asm,c.exe,,cs.lib

would be correct for tiny model

vasant

_Function name is ID For function from assembly of Turbo C 2.0
But I think is it have another code for compile it.