News:

How did you even find this place?

Main Menu

Joe's Files

Started by Joe, September 09, 2005, 08:01:39 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Joe

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
Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.


Warrior

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?
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Joe

I sort of lost interest again =p
Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.


MyndFyre


  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?
Quote from: Joe on January 23, 2011, 11:47:54 PM
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Quote from: Rule on May 26, 2009, 02:02:12 PMOur species really annoys me.

Warrior

The chaos that is to come if Joe continues in OSDev :P!
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Joe

Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.


Joe

Heh, I'm starting to actually understand how this stuff all works. This look better?

; 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
Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.


Warrior

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.
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Joe

What's a realmode segment?
Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.


Warrior

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.
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Joe

Oh. You told me to set those when we first started, so eh?
Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.


Warrior

I meant "arn't" you messing with them. Realmode is the never ending war against segments.
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling