problem using long variables with jloc

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
shahzad

problem using long variables with jloc

Post by shahzad »

hi,

i'm getting following error from jloc
undefined symbol N_LXMUL@ IN SYSTEM.C

my asm file is system.asm:

Code: Select all

[bits 16]
segment start

extern _main

jmp _main
my c file is system.c

Code: Select all

int main(void)
{
   long offset,start=66000,end=9;
   offset=start*end;
   for(;;);
}
my ctrl file is makefile.ctl

Code: Select all

ALL:
    system1.o
    system2.o

START: 0,000000000
   ,,,START
CODE: 0
   ,,code
DATA: 0,#10
   ,,data
BSS: 0,#10
   ,,bss

commands i'm using are

Code: Select all

nasm -f obj -osystem1.o system.c
tcc -c -osystem2.o syste.c

jloc makefile.ctl system.com
please help me to use long variables
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:problem using long variables with jloc

Post by Pype.Clicker »

the problem is that TCC (turbo C compiler) is a 16 bits compiler. It does not know anything about 32 bits registers or operations. In order to multiply long integers (32 bits), it requires a library that will provide the multiplication, division, etc. algorithms.

You should either locate that library and link with it or try to find a "enable 386 code" option for the compiler ... and hope it will allow it to generate native opcodes for 32 bits division (that the processor can handle, but that your compiler obviously ignores)
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:problem using long variables with jloc

Post by Pype.Clicker »

Reply from a duplicate thread ...
Tim Robinson wrote: Turbo C probably requires an external routine (whose name is N_LXMUL@) to multiply two 32-bit variables. Consider switching to a 32-bit compiler -- if you're running DOS, use DJGPP; if you're running Windows, use Cygwin or Mingw.
shah

Re:problem using long variables with jloc

Post by shah »

hi,


thanks for your reply.


should i include the 32 bit operations lirary in linker script.




should my linker script look like this now


{
ALL:


system1.o
ystem2.o
cs.lib /*cs.lib is 32 bit operations library*/


START: 0,000000000
,,,START
CODE: 0
,,code
DATA: 0,#10
,,data
BSS: 0,#10
,,bss

}



cs.lib in section "ALL" is 32 bit operations library
Tim

Re:problem using long variables with jloc

Post by Tim »

Maybe. I still think you're flogging a dead horse by using a 16-bit compiler. Move to 32 bits... :)
shahzad

Re:problem using long variables with jloc

Post by shahzad »

hi,

can you differnciate between 16 bit and 32 bit compiler.

and what are the disadvantages of using 16 bit compilers
Slasher

Re:problem using long variables with jloc

Post by Slasher »

it's like riding a bike in an F1 race. 16bit compilers are only capable of handling 16 bit data. To do 32bit stuff with a 16 bit compiler requires you to use an external assembler to compile the 32bit assembly code & data which the 16bit compiler can't handle.
eg 16 bit compilers on the x86 architecture can only handle registers ax,bx,.... and othe 16bit registers meaning the the upper 16bit part of the 32 bit registers like eax,ebx... can't be reached.
you might say but the compilers have long data types which are 32 bits. the compilers uses special library codes written in assembly which it links with your code to provide the needed support for the long data types. that why your having problems.
hope this helps
Post Reply