开发者

Building 16 bit os - character array not working

I am building a 16 bit operating system. But character array does not seem to work.

Here is my example kernel code:

asm(".co开发者_如何转开发de16gcc\n");
void putchar(char);

int main()
{
char *str = "hello";

putchar('A');
if(str[0]== 'h')
    putchar('h');

return 0;
}


void putchar(char val)
{

   asm("movb %0, %%al\n"  
       "movb $0x0E, %%ah\n" 
       "int $0x10\n"
      :
      :"m"(val)
     ) ;
}

It prints:

A

that means putchar function is working properly but

 if(str[0]== 'h')
        putchar('h');

is not working.

I am compiling it by:

gcc -fno-toplevel-reorder -nostdinc -fno-builtin -I./include -c -o ./bin/kernel.o ./source/kernel.c
ld -Ttext=0x9000 -o ./bin/kernel.bin ./bin/kernel.o -e 0x0

What should I do?


Your data segment is probably not loaded in to the target. What are you doing after the link with your brand new kernel.bin file, which is in fact an elf file ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜