Author Topic: mixing nasm and turbo c v2.0  (Read 2969 times)

nobody

  • Guest
mixing nasm and turbo c v2.0
« on: September 30, 2009, 07:22:40 AM »
Hello. I've got next error message mixing nasm and turbo c:

Turbo C  Version 2.01  Copyright (c) 1987, 1988 Borland International
tcasmn2.c:
Turbo Link  Version 2.0  Copyright (c) 1987, 1988 Borland International
Fixup overflow in module tcasmn2.c at _TEXT:0004, target = _wrtchar


Let's say:


AsmPN2.asm

segment _TEXT byte public

global _wrtchar ; (unsigned char car, short Col)

_wrtchar:

PUSH   BP

MOV    BP, SP

PUSH   AX

PUSH   DX

MOV    AH, 2

MOV    DL, BYTE [BP+4]

INT    21h

POP    DX

POP    AX

MOV    SP, BP

POP    BP


RET

; nasmw -f obj AsmPN2.asm -o AsmPN2.obj



TCAsmN2.c

#include
/* Llama a una rutina en ensamblador para rellenar la pantalla en AsmCM1.asm */
extern void wrtchar(unsigned char car);

char ch;

void main()
{
wrtchar('A');
ch = getchar();
exit(0);
}

/* nasmw -f obj AsmPN2.asm -o AsmPN2.obj

tcc TCasmN2.c AsmCN2.obj

Turbo C  Version 2.01  Copyright (c) 1987, 1988 Borland International
tcasmn2.c:
Turbo Link  Version 2.0  Copyright (c) 1987, 1988 Borland International
Fixup overflow in module tcasmn2.c at _TEXT:0004, target = _wrtchar
*/

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2377
  • Country: us
Re: mixing nasm and turbo c v2.0
« Reply #1 on: September 30, 2009, 08:01:32 AM »
Nasm's "-f obj" defaults to 16-bit code. We need to specify 32-bit sections:

segment _TEXT byte public use32

You may want "class=CODE" in there, too.

Best,
Frank