Where do i start??
Re:Where do i start??
Oh ok,
Well, i'm improving the code a bit, i'll post it a bit later. I am making functions for Reading from the disk etc, wow, i've come along way ;D
When i first started i didn't even know asm, now i even know how to make functions ;D
Special thanks ro PlayOS for explaining functions in asm to me (It's in a previous post on this thread)
I'll post the code a bit later ;D
Cya.
Well, i'm improving the code a bit, i'll post it a bit later. I am making functions for Reading from the disk etc, wow, i've come along way ;D
When i first started i didn't even know asm, now i even know how to make functions ;D
Special thanks ro PlayOS for explaining functions in asm to me (It's in a previous post on this thread)
I'll post the code a bit later ;D
Cya.
Re:Where do i start??
Hi,
Ok, here's my Kernel:
As you can see it isn't much of a Kernel, but i just can't get it to PrintText!
The MainFunction is called from an asm module (it's in a previous post)
Does anybody know what could be wrong?
I don't think it's anything with the BootLoader.
So, does anybody know what could be wrong?
Ok, here's my Kernel:
Code: Select all
extern "C" void MainFunction(void);
void printf(char *msg, unsigned int line)
{
unsigned short* video = (unsigned short*)0xB8000;
unsigned int i = 0;
i = (line * 80 * 2);
while (*msg != 0)
{
if (*msg == '\n') // check for a new line
{
line++;
i = (line * 80 * 2);
*msg++;
}
else
{
video[i] = *msg;
*msg++;
i++;
video[i] = 0x02; // black on green text
i++;
}
}
}
//Kernels MainFunction
void MainFunction(void)
{
printf("Hello World!", 5);
}
The MainFunction is called from an asm module (it's in a previous post)
Does anybody know what could be wrong?
I don't think it's anything with the BootLoader.
So, does anybody know what could be wrong?
Re:Where do i start??
Hi Everybody,
Nope, my Kernel is Fine, it's something with the BootSector and Second Stage Loader, i can't seem to figure out what the heck is wrong?
I tried my Kernel with somebody else's BootSector, and it works fine. But with mine it doesn't.
I am going to post my BootSector & SSL Here, Sorry, but i just can't see what is wrong, i have been trying for a couple of hours and i just can't figure it out.
So Somebody Please help out if you can...
That is my BootSector, My ssl is in the next post --|under this one ;D
Nope, my Kernel is Fine, it's something with the BootSector and Second Stage Loader, i can't seem to figure out what the heck is wrong?
I tried my Kernel with somebody else's BootSector, and it works fine. But with mine it doesn't.
I am going to post my BootSector & SSL Here, Sorry, but i just can't see what is wrong, i have been trying for a couple of hours and i just can't figure it out.
So Somebody Please help out if you can...
Code: Select all
[BITS 16]
[ORG 0x7C00]
;Jump over the Functions & Variables, and goto the BootCode!
jmp 0x0000:BootCode
BootDrive db 0 ;Stores the BootDrive Number
_ReadDisk:
push es
push bp
mov bp, sp
Reset_FloppyDisk_Drive:
mov ax, 0x00 ;Select Reset Function
int 0x13 ;Reset!
jc Reset_FloppyDisk_Drive ;If there is an Error, Try Again!
Read_FloppyDisk_Sectors:
mov ax, [bp + 16] ;Segment to load DiskData to
mov es, ax
mov bx, [bp + 14] ;Offset
mov ah, 0x02 ;Get the Segment:Offset from ES:BX
mov ch, [bp + 12] ;Cylinder
mov dh, [bp + 10] ;Head
mov al, [bp + 8] ;Sectors to Read
mov cl, [bp + 6] ;Sector to Start Reading at
int 0x13 ;Read!
jc Read_FloppyDisk_Sectors ;If there is an Error, Try Again!
pop bp
pop es
ret 12
BootCode:
;Set all the Segment Registers to 0
mov ax, 0
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
;Save the BootDrive number
mov [BootDrive], dl
;Setup a RM (Real Mode) Stack
cli ;Disable Interrupts
mov ax, 0x9000 ;Stack Segment
mov ss, ax
mov sp, 0xFFFF ;Use the whole segment
mov ax, cs
mov ds, ax ;Set DS == CS
sti ;Enable Interrupts
;Clear the Screen (Changing the Graphics Mode Clears the Screen!)
mov ah, 0x00 ;Select, Change Graphics Mode Function
mov al, 0x03 ;Select Text Mode 3 as a Graphics Mode
int 0x10 ;Call Video Interrupt
;Read in BootLoader
ReadIn_BootLoader:
mov dl, [BootDrive] ;FloppyDisk Drive to Read From
push 0x0000 ;Segment to load DiskData to
push 0x7E00 ;Offset
push 0 ;Cylinder
push 0 ;Head
push 4 ;Sectors to Load
push 2 ;Sector to Start Loading at
call _ReadDisk ;Read!
;Jump to the BootLoader
JumpTo_BootLoader:
mov dl, [BootDrive] ;Save the BootDrive for use in the BootLoader!
jmp 0x0000:0x7E00 ;Jump to the BootLoader
CodePadding times 510-($-$$) db 0 ;Makes sure the Code is 512 Bytes
BootSignature dw 0xAA55
Re:Where do i start??
Here's my second stage loader:
If somebody could please go through it and help me find what's wrong, i have been trying to find out for hours, but it just doesn't work :'( :'( :'( :'( :'(
Thanks in Advance.....
Code: Select all
[BITS 16]
[ORG 0x7E00]
;Jump over the Functions & Variables, and goto the BootCode!
jmp StartOf_Code
BootDrive db 0
;A Pointer to the location of the GlobalDescriptorTable!
GDT:
dw 0xFFFF
dd 0x00010000
_ReadDisk:
push es
push bp
mov bp, sp
Reset_FloppyDisk_Drive:
mov ax, 0x00 ;Select Reset Function
int 0x13 ;Reset!
jc Reset_FloppyDisk_Drive ;If there is an Error, Try Again!
Read_FloppyDisk_Sectors:
mov ax, [bp + 16] ;Segment to load DiskData to
mov es, ax
mov bx, [bp + 14] ;Offset
mov ah, 0x02 ;Get the Segment:Offset from ES:BX
mov ch, [bp + 12] ;Cylinder
mov dh, [bp + 10] ;Head
mov al, [bp + 8] ;Sectors to Read
mov cl, [bp + 6] ;Sector to Start Reading at
int 0x13 ;Read!
jc Read_FloppyDisk_Sectors ;If there is an Error, Try Again!
pop bp
pop es
ret 12
;PutPixel Function for graphics mode 13
_PutPixel:
push es
push bp
mov bp, sp
mov ax, 0x0A000
mov es, ax
mov ax, 320
mov bx, [bp + 8]
mul bx
mov di, ax
add di, [bp + 10]
mov al, [bp + 6]
stosb
pop bp
pop es
ret 6
StartOf_Code:
mov [BootDrive], dl
;Read in Kernel
ReadIn_Kernel:
mov dl, [BootDrive] ;Drive to Read From
push 0 ;Segment to load DiskData to
push 0x5000 ;Offset
push 0 ;Cylinder
push 0 ;Head
push 10 ;Sectors to Load
push 6 ;Sector to Start Loading at
call _ReadDisk ;Read!
jmp Enter_ProtectedMode
;Enter PM (Protected Mode)
Enter_ProtectedMode:
;Disable Interrupts
cli
;Move the GDT into Memory
mov ax, 0x1000
mov es, ax
mov si, GlobalDescriptorTable
xor di, di
mov cx, 6
cld
rep movsd
;Load the GDT (Global Descriptor Table) Pointer
lgdt [GDT]
;Set PM (ProtectedMode) Bit
mov eax, cr0
or eax, 1
mov cr0, eax
;Jump into PM Code
jmp 0x08:In_ProtectedMode
[BITS 32]
;This is where Protected Mode is Entered!
In_ProtectedMode:
;Put the Data Selector into eax for setting up other registers
mov eax, 0x10
;Make SS, DS, ES, FS and GS = The Data Selector
mov ss, eax
mov ds, eax
mov es, eax
mov fs, eax
mov gs, eax
;Set up a Protected Mode Stack
mov eax, 0x10
mov ss, eax
mov esp, 0x300000
;Stop the FloppyDisk Drive Motor from Spinning
Stop_FloppyDisk_Drive_Motor:
mov dl, [BootDrive]
;Select - Stop FloppyDisk Drive Motor Function!
mov edx, 0x3F2
mov al, 0x0C
;Stop the Motor:
out dx, al
jmp 0x5000
GlobalDescriptorTable:
;Null 0x00 Descriptor
dd 0
dd 0
;CodeSegment 0x08 Descriptor
db 11111111b
db 11111111b
db 00000000b
db 00000000b
db 00000000b
db 10011010b
db 11001111b
db 00000000b
;DataSegment 0x10 Descriptor
db 11111111b
db 11111111b
db 00000000b
db 00000000b
db 00000000b
db 10010010b
db 11001111b
db 00000000b
EndOf_GlobalDescriptorTable
CodePadding times 2048-($-$$) db 0
Thanks in Advance.....
Re:Where do i start??
Hey,
Ahhh, it was just a misunderstanding :-[ the code works now. It's amazing how one little thing can screw up the whole thing ;D
Anyways, could one of the moderators please delete this post and my other recent posts about this, because i think that all the code is crowding the thread :-[
So, Could one of the mods please delete the posts that you think don't have any useful info ;D
Ciao.
Ahhh, it was just a misunderstanding :-[ the code works now. It's amazing how one little thing can screw up the whole thing ;D
Anyways, could one of the moderators please delete this post and my other recent posts about this, because i think that all the code is crowding the thread :-[
So, Could one of the mods please delete the posts that you think don't have any useful info ;D
Ciao.
Re:Where do i start??
Damn right your code is crowding the thread. If I see any more code listings from you, I will delete the posts on sight.Anyways, could one of the moderators please delete this post and my other recent posts about this, because i think that all the code is crowding the thread
Re:Where do i start??
... so tempting to make a comment... but will resistBerserk wrote: Could one of the mods please delete the posts that you think don't have any useful info
Re:Where do i start??
I know i know, most of my posts are pointless, and probably annoying. I'm just glad that my Kernel Works ;D
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Where do i start??
bersek, you strik3 on my n3rv3s ... if you wish to delete your p0sts, the become a member.Berserk wrote: Then delete it.....
Re:Where do i start??
Yes. And when you get your board up, Berserk, you can even edit and delete and whatever you want when you a administrator.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Where do i start??
allelluia ...
hum, anyway, i don't feel like browsing those 9 pages again ... this thread has turned to a complete mess ... i think the best thing to do is to lock it and to get a fresh start ...
hum, anyway, i don't feel like browsing those 9 pages again ... this thread has turned to a complete mess ... i think the best thing to do is to lock it and to get a fresh start ...