Author Topic: calling 'C' functions  (Read 2194 times)

Zulfi Khan

  • Guest
calling 'C' functions
« on: July 09, 2009, 06:28:28 AM »
Hi,
I want to call C functions from my 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


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

D:\NASMPR~1>
msg db 'Welcome to the Kernel!', 0

times 0x200-($-$$) db 0

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2446
  • Country: us
Re: calling 'C' functions
« Reply #1 on: July 10, 2009, 02:48:41 PM »
We've kinda moved this discussion to the nasm-users list. (do join us!) The "trick", in this case, is simply "-f obj" instead of "-f bin". (then... we don't really want an .exe for this - exe2bin seems to be helping?)

Best,
Frank