• Forum
  • Lounge
  • Bootloader loaded at memory location oth

 
Bootloader loaded at memory location other than 0x00007c00

Recently I got interested in programming a bootloader.
So I made a simple boot loader that would just check for the first 'filled' memory location starting from 0x00 and show the next 512 bytes (which should be the 512 bytes of the bootloader).

Probably this first 'filled' meory should be the first byte of the bootloader where it is loaded. Traditionally a bootloader is loaded at 0x00007c00. But the program is outputting that the bootloader was loaded at 0x00.

How is this possible ? It gives the same result in a virtual machine as well as real machine. Please help.

Here is the bootloader :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
BITS 16

start:
	mov ax, 07C0h		; Set up 4K stack space after this bootloader
	add ax, 288		; (4096 + 512) / 16 bytes per paragraph
	mov ss, ax
	mov sp, 4096

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


	mov si, text_string	; Put string position into SI
	call print_string	; Call our string-printing routine

	jmp find

	jmp $			; Jump here - infinite loop!


	text_string db 'Ram contents from 0x7c0:0x0000 are : ', 0
	ram_byte db 65

print_string:			; Routine: output string in SI to screen
	mov ah, 0Eh		; int 10h 'print char' function

.repeat:
	lodsb			; Get character from string
	cmp al, 0
	je .done		; If char is zero, end of string
	int 10h			; Otherwise, print it
	jmp .repeat

.done:
	ret

find:
	mov cx,65535
	mov edx,0
again:
	mov al,[edx]
	cmp al,0
	jne print
	inc edx
	dec cx
	cmp cx,0
	jne again
	hlt

print:
	mov ah,0eh
	mov cx,512
print_again:	mov al,[edx]
	int 10h
	inc edx
	dec cx
	cmp cx,0
	jne print_again
	sub edx,512         ;Make edx equal to the loaction where it first found the non-zero byte
	ror edx,24         ; 
	mov al,dl          ;
	int 10h            ;
	rol edx,8          ;
	mov al,dl          ;
	int 10h            ;
	rol edx,8          ; Output the contentes of edx 
	mov al,dl          ;
	int 10h            ;
	rol edx,8          ;
	mov al,dl          ;
	int 10h            ;
	jmp $              ; Jump here
	
	
	times 510-($-$$) db 0	; Pad remainder of boot sector with 0s
	dw 0xAA55		; The standard PC boot signature
 
If you haven't already, divert to:
http://forum.osdev.org/

Also, I remember that if you recklessly overwrite the entire 512 bytes you'll also overwrite the partition table. So be careful.
http://wiki.osdev.org/MBR_%28x86%29#MBR_Format
I have seen that site.
I am currently booting from a CD-ROM.
Last edited on
letscode wrote:
I have seen that site.
When he said 'divert to' he didn't mean 'go look at it' he meant 'go sign up and post a topic there instead of here'. 99.99% of people on this forum have little to no knowledge of what you're asking about, you'll get better help there instead.
hmm never tried to boot from different address but I assume it is due to the standard boot address.
I hate that osdev.org.
It's been 3 days and I haven't got any activation e-mail.
Try again, I got mine very quickly.
I did. Now I have 3 accounts on gmail and none of them has received any activation e-mail. Moreover I can't sign up twice using the same account (that's obvious)
I'm assuming that you have checked your spam box (things like that occasionally go there, it did for me).
Yesssss, thank you so much NT3
letscode wrote:
Now I have 3 accounts on gmail and none of them has received any activation e-mail.


letscode wrote:
Yesssss, thank you so much NT3

*triple facepalm*
Ha ha "triple facepalm"
But why should it have gone in the spam box anyways
But why should it have gone in the spam box anyways

Well spam filters can be stupid like that.

They probably go like "Hey did the user ever send an email to osdev.org? No? Then why is osdev.org sending him an e-mail, out of nowhere? Spam."
Topic archived. No new replies allowed.