From: zak100 <zul...@ya...> - 2009-07-17 05:05:06
|
Hi, Thanks for your help. I have received your mz folder. It has two binaries: boot and image. 'boot' is fine but when i tried to load image to sector 2 it didnt work. Maybe I am doing something wrong. However, I didnt find any 'C' files. Still waiting for your response in this regard. Zulfi. Frank Kotler-3 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] >> ;--- test kernel.bin--- >> >> ; push cs >> ; push cs >> ; pop ds >> ; pop es >> mov ax, 7E0H >> mov ds,ax >> mov es,ax >> mov si, msg >> >> mov ah, 0Eh >> mov bx, 7 >> top: >> lodsb >> cmp al, 0 >> jz blackhole >> int 10h >> jmp short top >> >> blackhole: >> >> mov cx,1000 >> Delay: Loop Delay >> call _K_main; this is in main.c >> hlt >> jmp blackhole >> >> msg db 'Welcome to the Kernel!', 0 >> >> times 0x200-($-$$) db 0 >> >> >> I am getting following error mesg: >> D:\nasm prog>nasm -f bin -o boot.bin test_kernel2.asm >> test_kernel2.asm:5: error: label or instruction expected at start of line > > Hi Zulfi, > > Removing the brackets will at least give you correct syntax (extern > _K_main), but binary format still doesn't know about external > references. What format is your proposed _K_main in? OMF probably, for > 16-bit code(???). > > Try assembling with "nasm -f obj test_kernel2.asm" this will produce > "test_kernel2.obj", by default. If your linker won't handle long file > names, you can shorten it with the "-o" switch, but your linker is > probably going to be happier with ".obj" than ".bin" (maybe not?). > > Then... your linker is probably going to want to produce an MZ > executable by default. I don't think it's too hard to write a loader for > MZ, but it might be easier to persuade your linker to produce a .com > file. I believe ld (for 32-bit Linux - won't help you) can be coerced to > produce a flat binary, explicitly specifying origins for the various > sections (if you know how - I don't). If your linker will do that, > you're in luck. Failing that... I dunno. > > Make sure your compiler isn't producing any "dosisms" in your C code, of > course. > > The OS-development guys may have better advice on this. > > Best, > Frank > > P.S. Thanks for asking here, rather than nasm-devel, Zulfi! :) > > > ------------------------------------------------------------------------------ > 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-tp24404865p24528638.html Sent from the nasm-users mailing list archive at Nabble.com. |