From: zak100 <zul...@ya...> - 2009-07-10 06:11:04
|
Hi, I am able to make the binary using alink. partcopy was giving prob but it was handled as done previously. The steps are provided below: D:\nasm prog>nasm -f bin -o boot.bin BLKernelT.asm D:\NASMPR~1>nasm -f bin -o writeit.com writeit.asm D:\NASMPR~1>writeit D:\NASMPR~1>del test_kernel2.onj Could Not Find D:\NASMPR~1\test_kernel2.onj D:\NASMPR~1>del test_kernel2.obj D:\NASMPR~1>nasm -f obj test_kernel2.asm D:\NASMPR~1>dir t*.obj Volume in drive D is New Volume Volume Serial Number is 70FD-1D2C Directory of D:\NASMPR~1 07/10/2009 10:55 AM 642 test_kernel2.obj 1 File(s) 642 bytes 0 Dir(s) 22,656,360,448 bytes free D:\NASMPR~1>alink -o kernel.bin test_kernel2.obj main1.o ALINK v1.6 (C) Copyright 1998-9 Anthony A.J. Williams. All Rights Reserved Loading file test_kernel2.obj Loading file main1.o matched Externs matched ComDefs Warning, no entry point specified Warning - no stack D:\NASMPR~1>alink -o kernel.exe test_kernel2.obj main1.o ALINK v1.6 (C) Copyright 1998-9 Anthony A.J. Williams. All Rights Reserved Loading file test_kernel2.obj Loading file main1.o matched Externs matched ComDefs Warning, no entry point specified Warning - no stack D:\NASMPR~1>del kernel.bin D:\NASMPR~1>exe2bin kernel.exe kernel.bin D:\NASMPR~1>partcopy kernel.bin 0 200 -f0 200 Failed to read source at offset 144 D:\NASMPR~1>partcopy kernel.bin 0 144 -f0 200 D:\NASMPR~1> ----------------------------------- But when I rebooted , I got boot sector statment but I am not seeing the "welcome....." kernel message. Can somebody plz guide me?? Zulfi. zak100 wrote: > > 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-tp24404865p24422303.html Sent from the nasm-users mailing list archive at Nabble.com. |