Bochs error

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Samathy
Posts: 6
Joined: Sat Mar 17, 2012 4:02 am

Bochs error

Post by Samathy »

hey,
i started developing a boot loader for my kernel a few weeks back but every time i test it using Bochs i get this error:
'00014058132i[CPU0 ] BOUND_GdMa: fails bounds test' and i get no output.
i did a few search and read that this error seems to be because of an incorrectly set up stack.
But what confuses me is no matter what method i use to set up the stack,
whether i read about it and write my own code or steal it from another boot loader from some tutorial, i still get this error.
what im asking is what does this error acctually mean, how can i fix it and how do you go about setting up the stack?

further info:
my boot loader is in NASM assembly,
it loads the kernel from the second sector of the floppy then jumps to the kernel. simples.

here is the code:

Code: Select all

; ================================
;OS/B boot loader
; ================================
msg_wait db "press any key to boot kernel", 0x0D, 0x0A , 0
org 0x07C0
;==============================================================================
;this is from MikeOS, because no matter how hard i try i cant get any sort of stack set up to work :(

	mov ax, 07C0h			; Set up 4K of stack space above buffer
	add ax, 544			; 8k buffer = 512 paragraphs + 32 paragraphs (loader)
	cli				; Disable interrupts while changing stack
	mov ss, ax
	mov sp, 4096
	sti				; Restore interrupts

	mov ax, 07C0h			; Set data segment to where we're loaded
	mov ds, ax
;================================================================================
 

 ;ok, load the kernel from the second sector of the floppy drive into 0x1000 of the RAM
 
 mov si, msg_wait
call print_string
   mov ah, 0
   int 0x16   ; wait for keypress
      mov dl, 0x00 ;drive is set as first floppy
   mov ah,0x00  ; reset drive
   int 0x13
   mov ax, 0x1000  ;memory adress for second sector to be loaded into
   mov cl, 2       ;sector to be read
   mov al, 1       ;number of sectors to be read
   mov dh, 0       ;head
   mov ch, 0       ;track
   mov ah, 0x02    ;set up interrupt
   mov bx, 0
   int 0x13        ;go go go!
   jmp 0x1000
   

 cli
 hlt
 
 ; ================
 ; calls ( from an OSDev tutorial, called something like 'writing a 16 bit real mode OS' i think...)
 ; ================
 
 print_string:
   lodsb        ; grab a byte from SI
 
   or al, al  ; logical or AL by itself
   jz .done   ; if the result is zero, get out
 
   mov ah, 0x0E
   int 0x10      ; otherwise, print out the character!
 
   jmp print_string
 
 .done:
   ret
 
   
   

 
   times 510-($-$$) db 0 ;fill whatever is left of the first sector with 0's
   dw 0AA55h ; BIOS boot sig
thanks in advance :)
Who is the more foolish, the fool or the fool who follows him?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Bochs error

Post by Brendan »

Hi,
Samathy wrote:

Code: Select all

   mov ax, 0x1000  ;memory adress for second sector to be loaded into
   mov cl, 2       ;sector to be read
   mov al, 1       ;number of sectors to be read
   mov dh, 0       ;head
   mov ch, 0       ;track
   mov ah, 0x02    ;set up interrupt
   mov bx, 0
   int 0x13        ;go go go!
This BIOS function loads sectors at the address ES:BX. ES is never set anywhere. The BIOS might have left ES set to 0x07C0 so that the data you read overwrites the code you're executing, but the BIOS may also have left ES set to anything (so you could be trashing anything).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Samathy
Posts: 6
Joined: Sat Mar 17, 2012 4:02 am

Re: Bochs error

Post by Samathy »

ah,thanks you, i see
so because ES is not set i could not be loading the sectors at all, or loading them someplace random?
how would i set ES so my kernel is loaded directly after the bootloader?
Thanks.
Who is the more foolish, the fool or the fool who follows him?
assembler01
Member
Member
Posts: 25
Joined: Mon Feb 27, 2012 9:46 am

Re: Bochs error

Post by assembler01 »

Here is how you whould setup ES:

Code: Select all

mov bx, 0x1000 ; your load segment
mov es, bx
xor bx, bx
And remember: as Brendan said, the bios loads sectors at es:bx.
Talk is cheap, show me the code. - Linus Torvalds
assembler01
Member
Member
Posts: 25
Joined: Mon Feb 27, 2012 9:46 am

Re: Bochs error

Post by assembler01 »

No wait, here is the error:
Samathy wrote:

Code: Select all

; ================================
;OS/B boot loader
; ================================
msg_wait db "press any key to boot kernel", 0x0D, 0x0A , 0
org 0x07C0
;==============================================================================
[/quote]
Never ever put data in code, you would need to jump over the data to the code.
Talk is cheap, show me the code. - Linus Torvalds
Samathy
Posts: 6
Joined: Sat Mar 17, 2012 4:02 am

Re: Bochs error

Post by Samathy »

ah, silly human error then!
thank you anyway, learnt alot in a few minuets!
Who is the more foolish, the fool or the fool who follows him?
Post Reply