Bootsector succesfully loading stage 2 but not jumping to it

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
madanra
Member
Member
Posts: 150
Joined: Mon Sep 07, 2009 12:01 pm

Bootsector succesfully loading stage 2 but not jumping to it

Post by madanra »

I've been writing the bootsector for my OS, it loads a 2nd stage loaded to 0050:0000, and is supposed to jump to it.
I've verified that the code has been loaded to 0050:0000 using:

Code: Select all

mov bx,0x0050
mov es,bx
mov ax,0x1301 ; BIOS output string, update cursore
mov bx,0x0007 ; Page 0, grey-on-black
mov cx,0x0040 ; 64 characters
xor dx,dx ; top left of screen
xor bp,bp ; es:bp = 0050:0000
int 0x10
but neither

Code: Select all

jmp 0050:0000
nor

Code: Select all

push word 0x0000
push word 0x0050
retf
transfers control to the 2nd stage loader.
Currently the 2nd stage loader just outputs a few characters using BIOS teletype (int 0x10, ah=0x0e), but these aren't coming up at all.
Interrupts are disabled throughout the code (well, cli is the first instruction and there are no cli/sti elsewhere in my code...)
This has got me completely stuck...
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Bootsector succesfully loading stage 2 but not jumping to it

Post by AJ »

Hi,

Could I suggest adding cli/hlt as the first instruction of Stage 2 and then running in Bochs / Qemu. Where is CS:IP when the system halts?

Cheers,
Adam

[Edit: Just a thought - you set CS on your far jump, but do you correctly set DS before trying to use teletype in stage 2?]
madanra
Member
Member
Posts: 150
Joined: Mon Sep 07, 2009 12:01 pm

Re: Bootsector succesfully loading stage 2 but not jumping to it

Post by madanra »

Thank you, error found: I'd written 0050 instead of 0x0050 in the jump...so I was attempting to execute the interrupt table!!!
I knew it would be something absurdly silly like that...just couldn't spot it without the info Bochs gave me in the log!
Last edited by madanra on Wed Sep 09, 2009 9:21 am, edited 1 time in total.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Bootsector succesfully loading stage 2 but not jumping to it

Post by AJ »

np, we've all done something like that before :)

Cheers,
Adam
Post Reply