Discussion:
Turbo C linking error
(too old to reply)
Peter Wiehe
2020-04-06 14:33:14 UTC
Permalink
Hi all!

I use Turbo C.

I have a very small C program and a very small Assembler file.

When I try to link them together to an EXE file, there comes an error:
"Fixup overflow". This happens with the memory models "tiny" and "small".

With the models medium, large and huge, when I run the linked program, I
get the error "Invalid opcode ..."

---------My C code:--------
extern printChar(char c);

main()
{
printChar('+');

while(1){;}
}
--------------------------

---------My Asm code:-----
section code

global _printChar
_printChar: mov al, '+'
mov ah, 0x0E
mov bx, 7
int 0x10
ret

section data
--------------------------

What can I do to solve this error?

(And please note, that I'm aware that the argument for printChar is
ignored. I'm just building it up, step by step).
--
Greetings
Peter Wiehe
T. Ment
2020-04-06 17:28:53 UTC
Permalink
Post by Peter Wiehe
I use Turbo C.
I have a very small C program and a very small Assembler file.
"Fixup overflow". This happens with the memory models "tiny" and "small".
With the models medium, large and huge, when I run the linked program, I
get the error "Invalid opcode ..."
---------My C code:--------
extern printChar(char c);
main()
{
printChar('+');
while(1){;}
}
--------------------------
---------My Asm code:-----
section code
global _printChar
_printChar: mov al, '+'
mov ah, 0x0E
mov bx, 7
int 0x10
ret
section data
--------------------------
What can I do to solve this error?
You did't say which version of Turbo C, linker, or assembler. The .asm
source doesn't look like TASM syntax. Using a non-Borland assembler with
Borland tlink is asking for trouble.

Read this:

http://files.mpoli.fi/unpacked/software/programm/c/c_all.zip/ti1150.asc
Alexei A. Frounze
2020-04-06 19:35:07 UTC
Permalink
Post by Peter Wiehe
Hi all!
I use Turbo C.
I have a very small C program and a very small Assembler file.
I'm assuming you're using NASM here?
Post by Peter Wiehe
"Fixup overflow". This happens with the memory models "tiny" and "small".
With the models medium, large and huge, when I run the linked program, I
get the error "Invalid opcode ..."
---------My C code:--------
extern printChar(char c);
main()
{
printChar('+');
while(1){;}
}
--------------------------
---------My Asm code:-----
section code
global _printChar
_printChar: mov al, '+'
mov ah, 0x0E
mov bx, 7
int 0x10
ret
section data
--------------------------
What can I do to solve this error?
(And please note, that I'm aware that the argument for printChar is
ignored. I'm just building it up, step by step).
I've found the right kind of segment declarations in
NASM to be compatible with Turbo/Borland C/C++:

SEGMENT _TEXT PUBLIC CLASS=CODE USE16
SEGMENT _DATA PUBLIC CLASS=DATA
SEGMENT _BSS PUBLIC CLASS=BSS

There's also a way to define a stack segment, e.g.:

SEGMENT _STACK STACK CLASS=STACK
resb 512

Alex

Loading...