Page 1 of 1

need some help

Posted: Sun Jun 06, 2004 1:25 am
by Johnny
I made very simple bootloader and kernel

Code: Select all

   unsigned short *vidmem = (unsigned short*) 0xb8000;
   vidmem[0] = '$' | 0x0700;
   
   for (;;)
      ;
Above is my kernel code
It is expect to print '$' out but it doesn't print out

What my boot load do is load kernel in 0x10000 and
jump to kernel

Everything is fine
I check in boch whether kernel loaded or not..
Kernel is loaded and run..
But It doesn't print out
Disassembled code also looks strange..

Code: Select all


00000200  55                push bp
00000201  8BEC              mov bp,sp
00000203  51                push cx
00000204  C745FC0080        mov word [di-0x4],0x8000
00000209  0B00              or ax,[bx+si]
0000020B  8B45FC            mov ax,[di-0x4]
0000020E  66C7002407EBFE    mov dword [bx+si],0xfeeb0724
Can anyone tell me why?

ps. I didn't enter the protected mode..

Re:need some help

Posted: Sun Jun 06, 2004 2:16 am
by Candy

Code: Select all


00000200  55                push bp
00000201  8BEC              mov bp,sp
00000203  51                push cx
00000204  C745FC0080        mov word [di-0x4],0x8000
00000209  0B00              or ax,[bx+si]
0000020B  8B45FC            mov ax,[di-0x4]
0000020E  66C7002407EBFE    mov dword [bx+si],0xfeeb0724
Can anyone tell me why?
You don't enter pmode, and in rmode the code disassembles to this. The pmode code is:

Code: Select all

00000200  55                push ebp
00000201  8BEC              mov ebp,esp
00000203  51                push ecx
00000204  C745FC00800B00        mov dword [edi-0x4],0xB8000
0000020B  8B45FC            mov eax,[edi-0x4]
0000020E  66C7002407    mov word [eax],0x0724
00000213  EBFE              jmp 00000213
which does what you want. Pmode (32b) code doesn't work in non-pmode (16b) mode.

Re:need some help

Posted: Sun Jun 06, 2004 11:46 am
by Johnnyd
Thanks for your reply..

I used VC Development ToolKit

I realized they produce 32-bit protected mode code..

How to compile c code to work on realmode?

Re:need some help

Posted: Sun Jun 06, 2004 12:58 pm
by Curufir
Johnnyd wrote: How to compile c code to work on realmode?
You'll need a compiler that understands 16-bit real-mode with segmented addressing.

Most of the time it's far simpler to just write an assembly stub that switches to P-Mode and loads your kernel (Or use GRUB as your bootloader and avoid such hassles).

Once in P-Mode your compiler produced binaries should work fine.