i have been writting an os for the last weeks and its going fine i decided to try it on a real machine but it doesnt jump to kernel i have tried to use an hdd instead of an usb stick and it doesnt even get the bootloader as it gets on the usb stick
ive tried to search on the web and use other code but it just doesnt jump to kernel here is the boot code
[ORG 0x7c00]
[BITS 16]
CODE_SEG EQU gdt_code - gdt_start
DATA_SEG EQU gdt_data - gdt_start
jmp short biosBlock
nop
biosBlock:
jmp 0:start
start:
;umas checkagens
cli ;clear interrupts
mov ax, 0x00
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0x7c00
sti ;enables interrupts
.load_protected:
cli
lgdt[gdt_descriptor]
mov eax, cr0
or eax, 0x1
mov cr0, eax
jmp CODE_SEG:load32
;just using gdt so we can use all the memory :D 4GB
gdt_start:
gdt_nul:
dd 0x0
dd 0x0
;offset 0x8
gdt_code: ;cs should point to this
dw 0xffff
dw 0
db 0
db 0x9a
db 11001111b
db 0
;offset 0x10
gdt_data:
dw 0xffff
dw 0
db 0
db 0x92
db 11001111b
db 0
gdt_end:
gdt_descriptor:
dw gdt_end - gdt_start - 1
dd gdt_start
[BITS 32]
load32:
mov eax, 1
mov ecx, 100
mov edi, 0x0100000
call ata_lba_read
jmp CODE_SEG:0x0100000
ata_lba_read:
mov ebx, eax, ; Backup the LBA
; Send the highest 8 bits of the lba to hard disk controller
shr eax, 24
or eax, 0xE0 ; Select the master drive
mov dx, 0x1F6
out dx, al
; Finished sending the highest 8 bits of the lba
; Send the total sectors to read
mov eax, ecx
mov dx, 0x1F2
out dx, al
; Finished sending the total sectors to read
; Send more bits of the LBA
mov eax, ebx ; Restore the backup LBA
mov dx, 0x1F3
out dx, al
; Finished sending more bits of the LBA
; Send more bits of the LBA
mov dx, 0x1F4
mov eax, ebx ; Restore the backup LBA
shr eax, 8
out dx, al
; Finished sending more bits of the LBA
; Send upper 16 bits of the LBA
mov dx, 0x1F5
mov eax, ebx ; Restore the backup LBA
shr eax, 16
out dx, al
; Finished sending upper 16 bits of the LBA
mov dx, 0x1f7
mov al, 0x20
out dx, al
.next_sector:
push ecx
.try_again:
mov dx, 0x1f7
in al, dx
test al, 8
jz .try_again
; We need to read 256 words at a time
mov ecx, 256
mov dx, 0x1F0
rep insw
pop ecx
loop .next_sector
; End of reading sectors into memory
ret
times 510 - ($- $$) db 0
dw 0xAA55
make file code:
dd if=./bin/boot.bin >> ./bin/os.bin
dd if=./bin/kernel.bin >> ./bin/os.bin
dd if=/dev/zero bs=1048576 count=32 >> ./bin/os.bin
im using
dd if=os.bin of="the_usb"