Page 1 of 1

What is wrong with this bootloader?

Posted: Mon May 14, 2012 11:37 am
by Mikemk
I am trying to load and execute the second sector on the disk.

Code: Select all

bits 16
org 0x7c00

jmp asm_main
packet:
	db 0x10
	db 0
	dw 1
	dd 0x5000
	dq 2
asm_main:
	mov ah, 0x41
	mov bx, 0x55AA
	int 0x13
	jc normal_operation
	
	mov bx, packet
	mov [ds:si], bx
	int 0x13
	mov ah, 0xe
	mov al, "A"
	int 0x10
	jmp 0x500:0
normal_operation:
	mov ah, 0xe
	mov al, "N"
	int 0x10
	mov ah, 2
	mov al, 1
	mov ch, 0
	mov cl, 1
	mov dh, 0
	mov bx, 0x500
	mov [es:bx], bx
	jmp 0x500:0

times 510-($-$$) db 0
db 0x55
db 0xaa

Re: What is wrong with this bootloader?

Posted: Mon May 14, 2012 12:01 pm
by Combuster
The amount of instances where you're relying on uninitialized data and registers is actually not funny at all: DS, ES, SS, SP, SI. It's as if you just randomly smashed together the code as a demonstration of effort and then come here to get more.

You are aware of the Required Knowledge rule? Your debugging skills need a lot of improvement.

Re: What is wrong with this bootloader?

Posted: Mon May 14, 2012 1:13 pm
by Mikemk
I know the problem is something to do with the jmp commands

Re: What is wrong with this bootloader?

Posted: Mon May 14, 2012 1:15 pm
by Combuster
Actually, turns out your problem is reading :shock:

Did you even try to understand what I said? Since I now need to debug a problem between keyboard and chair, tell me, what did I mean?

Re: What is wrong with this bootloader?

Posted: Mon May 14, 2012 3:13 pm
by Mikemk
You said that the segment and stack point registers are uninitialized . . .which I guess kindof makes sense.

I'm guessing that your telling me that the segment registers are in the stack, so I need to set the stack in order to use them?

Re: What is wrong with this bootloader?

Posted: Mon May 14, 2012 3:23 pm
by AJ
Hi,

Locked before the flaming starts. Some hints:
m12 wrote:I'm guessing that your telling me that the segment registers are in the stack, so I need to set the stack in order to use them?
You are in a freestanding environment. There is no (sane) stack until you have initialised it and the segment registers do not contain (sane) values until you have initialised them. The values you load will depend on how you plan to do your real mode addressing.

I'm not going to spoonfeed you segment register values - a hint for suitable search terms would be along the lines of "segment:offset addressing", "real mode addressing" etc.

Theres also (IIRC) a decent tutorial on Bona Fide OS Development on the state of the PC after the BIOS hands your bootloader control.

Cheers,
Adam