From: zak100 <zul...@ya...> - 2009-07-10 05:07:14
|
Hi Peter and Frank, I am able to compile the code after removing the brackets but now I am getting prob with ld. D:\nasm prog>nasm -f elf test_kernel2.asm -o test.o D:\NASMPR~1>ld -o kernel.exe test.o main1.o test.o:(.text+0xa): relocation truncated to fit: R_386_16 against `.text' D:\NASMPR~1>dir k* Volume in drive D is New Volume Volume Serial Number is 70FD-1D2C Directory of D:\NASMPR~1 File Not Found D:\NASMPR~1> I downloaded alib but some files were missing. Thanks for your attention but I am still looking for more help on this using ld. In the meantime, i would be looking for alib again. Zulfi. Frank Kotler-3 wrote: > > H. Peter Anvin wrote: >> zak100 wrote: >>> Hi, >>> I am trying to call 'C" functions from my tiny kernel code. Can somebody >>> plz >>> help me with this? >>> ; call c function >>> extern [_K_main] >> >> That should be >> >> extern _K_main >> >> No brackets... > > Now why haven't I seen my reply to Zulfi... in which I point out that > "-f bin" isn't going to like it without the brackets, either? Maybe > "nasm-users" doesn't like me... > > Anyway... I tried the following experiment... Since I don't "do" C > (much), I made up a "fake" kmain, which simply prints the letter "K" on > the screen and returns. Assembled with "-f obj". Added a "..start:" > label to "test_kernel2", and assembled that with "-f obj". Since I've > got Alink working under Linux, I tried to link 'em with "alink -oCOM > test_kernel2.obj kmain.obj". Alink warns that it's discarding data at > offset... well, all of 'em... and produces a zero-length .com file. > That's not going to help. So tried "-oEXE". Got an .exe! Since I don't > have an MZ loader at hand, nor "exe2bin" (which might work), I simply > removed the header with a text editor. The offsets happened to work out > - I doubt if this will always be true! I think we're going to need a > proper MZ loader to handle relocations, eventually. But for now... > > I combined "boot.bin" with this result using "cat", and wrote the > resulting "image.bin" to floppy. Wrote that to floppy with "dd". Booted, > and after "Welcome to the kernel", saw 'K' printed... repeatedly. > Progress! > > This isn't exactly what you want to do, but leads me to believe that, > with the proper tools, it may not be as difficult as I imagined. (famous > last words...) > > Best, > Frank > > > ------------------------------------------------------------------------------ > Enter the BlackBerry Developer Challenge > This is your chance to win up to $100,000 in prizes! For a limited time, > vendors submitting new applications to BlackBerry App World(TM) will have > the opportunity to enter the BlackBerry Developer Challenge. See full > prize > details at: http://p.sf.net/sfu/Challenge > _______________________________________________ > Nasm-users mailing list > Nas...@li... > https://lists.sourceforge.net/lists/listinfo/nasm-users > > -- View this message in context: http://www.nabble.com/calling-%27C%27-functions-tp24404865p24421875.html Sent from the nasm-users mailing list archive at Nabble.com. |