Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 28th, 2004, 12:37 AM   #1
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
; This is a comment
[ORG 0x7C00];This just tells the program where it is in the memory. Not important
[BITS 16];Not important too.

jmp start	; Jump over BIOS parameter block

start:;The label for the start of the actual program

push cs;Put cs onto the stack
pop ds;Take it out and put it into ds


mov si,Print_loading  ;Print loading message
call printstring ;Call is like jump, but it goes back. Like a function


   ;The complicated bit: Loads the next program
mov ah,02h       ;When ah=, int13 reads a disk sector
mov al,4  	;Al is how many sectors to read
mov ch,0  	;The track to read from
mov cl,2  	;Sector Id
mov dh,0  	;Head
mov dl,0  	;Drive (0 is floppy)
mov bx,0x1000 	;Es and Bx put together are where to load the program too (see jmp 0x1000:0x00)
mov es,bx
mov bx,0x00
int 13h  ;Int 13 is all functions for disks

mov si,putdot     ;Print a ".".
call printstring

jmp 0x1000:0x00    ;Run Bootinit from stack.

printstring:      ;Print string routine.
mov ah,0eh 	;Mov ah into 0, so int 10 prints
stringloop: 	;The following code loads each seperate charcter so it can be printed
lodsb  	
cmp al,00 	;If al =0, then the string has all been loaded
je endstring
int 10h  ;When int 10 is called, and ah=, it prints
jmp stringloop
endstring:
ret  	;Ret returns



putdot    db '.',0
Print_loading db 13,10,'Loading Easy OS v0.01a...',0
times 425 db 0;wastes 425 bytes on purpose, so the sector is full (The program must be 512 bytes long)

I was looking at someone elses code, and right above printstring there is a jmp 0x1000:0x00. Why is it jumping there?

Here's the site: http://www.groovyweb.uklinux.net/index.php...your%20own%20os
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Nov 28th, 2004, 8:07 AM   #2
Eggbert
Professional Programmer
 
Eggbert's Avatar
 
Join Date: Nov 2004
Posts: 250
Rep Power: 5 Eggbert is on a distinguished road
>Why is it jumping there?
The key is here (especially the comment):
mov bx,0x1000 ;Es and Bx put together are where to load the program too (see jmp 0x1000:0x00)
mov es,bx
mov bx,0x00
The 0x1000 is the address of the first sector, and 0x00 is the byte offset within the sector. In short, it says jump to the boot sector.
Eggbert is offline   Reply With Quote
Old Nov 28th, 2004, 11:23 AM   #3
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Ahh. I feel dumb now. Don't know how I missed the comment. Thanks for the help. That made it clearer.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Nov 28th, 2004, 4:16 PM   #4
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
Back in the old say, before windows when writing a program the first executable location in memory was segment 0x1000 offset 0x0000 is I recall correctly, and I believe that is what the program comment was explaining.
__________________
Clifford Matthew Roche <geek@cliffordroche.com>
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:21 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC