Octocontrabass wrote:You're using DS and ES, but you never set them to known values. You must set the segment registers to known values before you can use them.
It may also be a good idea to set up your own stack instead of relying on the BIOS stack. The BIOS stack can be extremely small.
Edit: another possible cause of the error is the size of your disk image. Have you padded it to at least two sectors big?
Sorry you have short seeing the previous code and ive made a simple one since.
So I no more use DS and ES nor the stack.
For padding, here's a version that add it but still doesn't work.
Code: Select all
[bits 16]
[org 0x7C00]
Bootloader:
;{
jmp Bootloader.Code.Entry
;==========================================================================================================================================================================================================
; DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA
;==========================================================================================================================================================================================================
Bootloader.Data:
;{
.Drive: db 0
;}
Bootloader.EndData:
;==========================================================================================================================================================================================================
; END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA
;==========================================================================================================================================================================================================
;==========================================================================================================================================================================================================
; CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE
;==========================================================================================================================================================================================================
Bootloader.Code:
;{
.Entry:
;{
mov [Bootloader.Data.Drive], dl ; DL contains the drive ID used to boot.
mov al, "B"
mov ah, 0x0E
mov bh, 0x00
mov bl, 0x03
int 0x10
mov ah, 0x02 ; Read sectors function
mov al, 1 ; Number of sectors to read
mov ch, 0 ; Cylinder index
mov dh, 0 ; Head index
mov cl, 2 ; Sector entry to start reading data
mov dl, [Bootloader.Data.Drive] ; Drive ID
mov bx, Kernel.Code.Entry ; Pointer where to write the data read
int 0x13
jnc .NoDiskReadError
;{
mov al, "E"
mov ah, 0x0E
mov bh, 0x00
mov bl, 0x03
int 0x10
jmp $ ; $ represent the current line address, thus infinite loop
;}
.NoDiskReadError:
jmp Kernel.Code.Entry
;}
.EndEntry:
;}
Bootloader.EndCode:
;==========================================================================================================================================================================================================
; END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE
;==========================================================================================================================================================================================================
;}
EndBootloader:
times (510 - (EndBootloader - Bootloader)) db 0 ; Fill the 1st sector
BootMagicWord: dw 0xAA55 ; ...
Kernel:
;{
;==========================================================================================================================================================================================================
; DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA
;==========================================================================================================================================================================================================
Kernel.Data:
;{
;}
Kernel.EndData:
;==========================================================================================================================================================================================================
; END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA
;==========================================================================================================================================================================================================
;==========================================================================================================================================================================================================
; CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE
;==========================================================================================================================================================================================================
Kernel.Code:
;{
.Entry:
;{
mov al, "K"
mov ah, 0x0E
mov bh, 0x00
mov bl, 0x03
int 0x10
jmp $
;}
End.Entry:
;}
;==========================================================================================================================================================================================================
; END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE
;==========================================================================================================================================================================================================
;}
EndKernel:
times (512 - (EndKernel - Kernel)) db 0 ; Fill the 2nd sector