×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Problem linking files with tlink

Problem linking files with tlink

Problem linking files with tlink

(OP)
Hi. I was reading a book on asm and I am currently on a chapter where we are learning to link multiple source files to create a single .COM file. The book is using MASM but I am using TASM and I am having some trouble linking the source files. I have copied the source for each file directly out of the book and then assembled them. But, when I try to link them (by using tlink /t file1 file2) I get "Cannot generate COM file : invalid initial entry point address" I thought it sounded like something that had to do with missing an ORG 100h but I checked and it is there. Here is the source for file1 and file2 if that helps:

file1:

CODE_SEG SEGMENT PUBLIC
ASSUME CS:CODE_SEG
ORG 100h

EXTRN WRITE_DECIMAL:NEAR

TEST_WRITE_DECIMAL PROC NEAR
MOV DX, 12345
CALL WRITE_DECIMAL
INT 20h
TEST_WRITE_DECIMAL ENDP

CODE_SEG ENDS

END TEST_WRITE_DECIMAL

file2:
CODE_SEG SEGMENT PUBLIC
ASSUME CS:CODE_SEG

PUBLIC WRITE_HEX

WRITE_HEX PROC NEAR
PUSH CX
PUSH DX
MOV DH, DL
MOV CX, 4
SHR DL,CL
CALL WRITE_HEX_DIGIT
MOV DL, DH
AND DL, 0Fh
CALL WRITE_HEX_DIGIT
POP DX
POP CX
RET
WRITE_HEX ENDP

PUBLIC WRITE_HEX_DIGIT

WRITE_HEX_DIGIT PROC NEAR
PUSH DX
CMP DL, 10
JAE HEX_LETTER
ADD DL, "0"
JMP Short WRITE_DIGIT
HEX_LETTER:
ADD DL, "A"-10
WRITE_DIGIT:
CALL WRITE_CHAR
POP DX
RET
WRITE_HEX_DIGIT ENDP

PUBLIC WRITE_CHAR

WRITE_CHAR PROC NEAR
PUSH AX
MOV AH, 2
INT 21h
POP AX
RET
WRITE_CHAR ENDP

PUBLIC WRITE_DECIMAL

WRITE_DECIMAL PROC NEAR
PUSH AX
PUSH CX
PUSH DX
PUSH SI
MOV AX, DX
MOV SI, 10
XOR CX, CX
NON_ZERO:
XOR DX, DX
DIV SI
PUSH DX
INC CX
OR AX, AX
JNE NON_ZERO
WRITE_DIGIT_LOOP:
POP DX
CALL WRITE_HEX_DIGIT
LOOP WRITE_DIGIT_LOOP
END_DECIMAL:
POP SI
POP DX
POP CX
POP AX
RET
WRITE_DECIMAL ENDP

CODE_SEG ENDS

END

Now I have tried another source file from the book and I was able to link that to file2. I don't understand why this one worked and the other didn't. Here is the code again for both files in case that helps

new file1:

CGROUP GROUP CODE_SEG, DATA_SEG
ASSUME CS:CGROUP, DS:CGROUP

CODE_SEG SEGMENT PUBLIC
ORG 100h

EXTRN WRITE_HEX:NEAR
EXTRN WRITE_CHAR:NEAR

DISP_LINE PROC NEAR
XOR BX, BX
MOV CX, 16
HEX_LOOP:
MOV DL, SECTOR[BX]
CALL WRITE_HEX
MOV DL, ' '
CALL WRITE_CHAR
INC BX
LOOP HEX_LOOP
INT 20h
DISP_LINE ENDP

CODE_SEG ENDS

DATA_SEG SEGMENT PUBLIC
PUBLIC SECTOR
SECTOR DB 10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h
DB 18h, 19h, 1Ah, 1Bh, 1Ch, 1Dh, 1Eh, 1Fh
DATA_SEG ENDS

END DISP_LINE

file2:

CODE_SEG SEGMENT PUBLIC
ASSUME CS:CODE_SEG
ORG 100h


TEST_WRITE_DECIMAL PROC NEAR
MOV DX, 12345
CALL WRITE_DECIMAL
INT 20h
TEST_WRITE_DECIMAL ENDP

PUBLIC WRITE_HEX

WRITE_HEX PROC NEAR
PUSH CX
PUSH DX
MOV DH, DL
MOV CX, 4
SHR DL,CL
CALL WRITE_HEX_DIGIT
MOV DL, DH
AND DL, 0Fh
CALL WRITE_HEX_DIGIT
POP DX
POP CX
RET
WRITE_HEX ENDP

PUBLIC WRITE_HEX_DIGIT

WRITE_HEX_DIGIT PROC NEAR
PUSH DX
CMP DL, 10
JAE HEX_LETTER
ADD DL, "0"
JMP Short WRITE_DIGIT
HEX_LETTER:
ADD DL, "A"-10
WRITE_DIGIT:
CALL WRITE_CHAR
POP DX
RET
WRITE_HEX_DIGIT ENDP

PUBLIC WRITE_CHAR

WRITE_CHAR PROC NEAR
PUSH AX
MOV AH, 2
INT 21h
POP AX
RET
WRITE_CHAR ENDP

PUBLIC WRITE_DECIMAL

WRITE_DECIMAL PROC NEAR
PUSH AX
PUSH CX
PUSH DX
PUSH SI
MOV AX, DX
MOV SI, 10
XOR CX, CX
NON_ZERO:
XOR DX, DX
DIV SI
PUSH DX
INC CX
OR AX, AX
JNE NON_ZERO
WRITE_DIGIT_LOOP:
POP DX
CALL WRITE_HEX_DIGIT
LOOP WRITE_DIGIT_LOOP
END_DECIMAL:
POP SI
POP DX
POP CX
POP AX
RET
WRITE_DECIMAL ENDP

CODE_SEG ENDS

END TEST_WRITE_DECIMAL

Thanks for your time.

RE: Problem linking files with tlink

i think this is because two different code segments in the two files. in a com file, there should be only one code segment.

i don't know much but hope this will give you a hint.

RE: Problem linking files with tlink

Hey, if this ant too late, you have to go through 3 steps to create a .com out of a .asm file, first you use tasm i belive, then its tlink, or vice versa (i forget now) but then once youve got your .exe file, you need to use a program that converts .exe files to .com, i got a simple one called exe2bin.exe , should be able to find that on the net. Good luck with your asm

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close