Clan x86

Technical (Development, Security, etc.) => General Programming => Operating System Development => Topic started by: Joe on September 09, 2005, 08:01:39 pm

Title: Joe's Files
Post by: Joe on September 09, 2005, 08:01:39 pm
If I used a reference, I added a comment in the file.
There is no license on these files. I asume nobody here would go off and rip my work. Use them to learn, or to debug.

http://www.javaop.com/~joe/OSDEV/bootloader.asm
x86 ASM Bootloader
Untested
Title: Re: Joe's Files
Post by: Warrior on October 01, 2005, 12:30:30 pm
Sorry for my late reply, try incrementing a value to test how many times it fails and after so many times it just won't work. No use being stuck in an infinate loop if it's a bad floppy, right?
Title: Re: Joe's Files
Post by: Joe on October 01, 2005, 06:19:05 pm
I sort of lost interest again =p
Title: Re: Joe's Files
Post by: MyndFyre on October 03, 2005, 12:27:46 pm
Code: [Select]
  JMP 0x2000:0x0000           ; Jump to the kernel
RET
Warning: unreachable code detected.

Why have a ret instruction that can never be reached?  And what exactly would you be ret'ting from anyway?
Title: Re: Joe's Files
Post by: Warrior on October 03, 2005, 03:36:28 pm
The chaos that is to come if Joe continues in OSDev :P!
Title: Re: Joe's Files
Post by: Joe on October 03, 2005, 05:59:11 pm
oh noez~
Title: Re: Joe's Files
Post by: Joe on February 12, 2006, 02:37:11 pm
Heh, I'm starting to actually understand how this stuff all works. This look better?

Code: [Select]
; x86 Assembly Bootloader
; Author: William LaFrance

[BITS 16]
[ORG  0x7C00]
 
MOV BX,  0x2000              ; Segment location to read to
MOV ES,      BX              ; Segment location to read to (moves from temporary location)
MOV BX,  0x0000              ; Offset to read into
MOV AH,  0x0002              ; BIOS read sector function
MOV AL,  0x0001              ; Number of sectors to read
MOV CH,  0x0001              ; Track to read from
MOV CL,  0x0002              ; Sector to read from
MOV DH,  0x0001              ; Head to read from
MOV DL,  0x0000              ; Drive to read from
XOR EAX, EAX

.READ
INC EAX
CMP EAX, 3  ;If EAX = 3
JE .FAIL    ;Goto .FAIL
INT 0x0013
JC .READ
JMP 0x2000:0x0000

.FAIL
; I don't know, we do something really bad though!


TIMES 510-($-$$)    DB 0      ; Fills unused sector space with 0s
                    DW 0xAA55 ; Adds the bootloader signature to the ending
Title: Re: Joe's Files
Post by: Warrior on February 12, 2006, 04:54:52 pm
Why are you messing with Realmode segments? Unless of course you'd like to reset them in your second stage.

Try setting up a stack then pushing/popping registers to save thier state and regain the original values you set in the beginning.
It also doesn't make much sense to use 'EAX' in a 16bit enviroment.
Title: Re: Joe's Files
Post by: Joe on February 13, 2006, 06:10:19 am
What's a realmode segment?
Title: Re: Joe's Files
Post by: Warrior on February 13, 2006, 06:31:31 am
Segment registers ES,DS,FS,GS,SS, CS, etc..
They matter in realmode.

In protected mode you have the option of them not mattering (or seeming not to) by using 'Flat Model'
what you do is in your GDT (Global Descriptor Table) you set the base to 0 and limit to 0xFFFFFFFF which effectively
removes segmentation. Then you create a code and data kernel descriptor, set the DS regulary and do a far jump to set CS.

Google some tutorials on RealMode most good ones explain segments. Or even intro to protected mode tutorials.
Title: Re: Joe's Files
Post by: Joe on February 14, 2006, 07:53:31 am
Oh. You told me to set those when we first started, so eh?
Title: Re: Joe's Files
Post by: Warrior on February 14, 2006, 09:14:07 pm
I meant "arn't" you messing with them. Realmode is the never ending war against segments.