That can't work. period.SpiglerG wrote: The code is attached.
You need to switch to protected mode before you run code generated by GCC (be it from dev-cpp, linux, cygwin, djgpp or whatever).
That can't work. period.SpiglerG wrote: The code is attached.
I suggest taking a look at this link. It doesnt contain code, but it will tell you actually what you need to setup protected mode.Click here.so, could you help me? i need someone to correct and update the code in the .zip i posted. i know a simple method to switch to protected mode and load a gdt, but if someone could post some code, i'll be very happy.
You'll need a lot of patience when developing an OS/kernel. You could just as well start getting used to it now.SpiglerG wrote: i wonder only if you could help me with some code, because it will be faster.
It may be faster for you if we give code, but you will not learn anything from it. If you have problems with code you have tried to write to enable protected mode, we will be glad to help. We are not here to write your os for you, there are tons of tutorials on the net showing how to enable protected mode. Everything you need to enable protected mode is found in the link I gave you. This is what I used and I only had minor problems in getting my code to work. If you dont want to write your own code, use a premade bootloader such as Grub or download a premade protected mode bootloader found by searching the net. ::)i wonder only if you could help me with some code, because it will be faster.
[BITS 16]
[SEGMENT .text]
start:
mov ax, 0x0100 ;location where kernel is loaded
mov ds, ax
mov es, ax
cli
mov ss, ax ;stack segment
mov sp, 0xFFFF ;stack pointer at 64k limit
sti
cli ; Disable interrupts, we want to be alone
xor ax, ax
mov ds, ax ; Set DS-register to 0 - used by lgdt
lgdt [gdt_desc] ; Load the GDT descriptor
mov eax, cr0 ; Copy the contents of CR0 into EAX
or eax, 1 ; Set bit 0
mov cr0, eax ; Copy the contents of EAX into CR0
jmp 08h:clear_pipe ; Jump to code segment, offset clear_pipe
[BITS 32]
[global start]
[extern _k_main]
clear_pipe:
mov ax, 10h ; Save data segment identifyer
mov ds, ax ; Move a valid data segment into the data segment register
mov ss, ax ; Move a valid data segment into the stack segment register
mov esp, 090000h ; Move the stack pointer to 090000h
jmp 08h:01000h ; Jump to section 08h (code), offset 01000h
gdt_desc: ; The GDT descriptor
dw gdt_end - gdt - 1 ; Limit (size)
dd gdt ; Address of the GDT
call _k_main
cli ; stop interrupts
hlt ; halt the CPU
[SEGMENT .data]
gdt: ; Address for the GDT
gdt_null: ; Null Segment
dd 0
dd 0
gdt_code: ; Code segment, read/execute, nonconforming
dw 0FFFFh
dw 0
db 0
db 10011010b
db 11001111b
db 0
gdt_data: ; Data segment, read/write, expand down
dw 0FFFFh
dw 0
db 0
db 10010010b
db 11001111b
db 0
gdt_end: ; Used to calculate the size of the GDT
[SEGMENT .bss]
And what happens when you try it?here is the start.asm code i tryied:
In order to use ld, you have to use protected mode code. So 0x00000100 will not work as a load address because it is a read mode address. Try loading it to a higher address.ld.exe: warning: cannot find entry simbol start; defaulting to 00000100. I think is not a problem because the bootloader load the kernel at that address.
It has to be a protected mode address. Most people load their protected mode os at the 1MB mark because the memory area is free. You can load it lower, but there are certain regions below 1MB that are free and others that cannot be touched.So, i need to load it, say, at 0x1000 instead of 0x0100?If so, i need to modify the bootloader too.