Help! did I load something?

Programming, for all ages and all languages.
Tjaalie
Member
Member
Posts: 25
Joined: Mon Mar 21, 2005 12:00 am

Re: Help! did I load something?

Post by Tjaalie »

Maybe there is something wrong with my bochs?
I tried to directly boot the code from brokenthorn:

Code: Select all

;*********************************************
;	Boot1.asm
;		- A Simple Bootloader
;
;	Operating Systems Development Tutorial
;*********************************************

bits	16							; We are still in 16 bit Real Mode

org		0x7c00						; We are loaded by BIOS at 0x7C00

start:          jmp loader					; jump over OEM block

;*************************************************;
;	OEM Parameter block / BIOS Parameter Block
;*************************************************;

TIMES 0Bh-$+start DB 0

bpbBytesPerSector:  	DW 512
bpbSectorsPerCluster: 	DB 1
bpbReservedSectors: 	DW 1
bpbNumberOfFATs: 	DB 2
bpbRootEntries: 	DW 224
bpbTotalSectors: 	DW 2880
bpbMedia: 	        DB 0xF0
bpbSectorsPerFAT: 	DW 9
bpbSectorsPerTrack: 	DW 18
bpbHeadsPerCylinder: 	DW 2
bpbHiddenSectors:       DD 0
bpbTotalSectorsBig:     DD 0
bsDriveNumber: 	        DB 0
bsUnused: 	        DB 0
bsExtBootSignature: 	DB 0x29
bsSerialNumber:	        DD 0xa0a1a2a3
bsVolumeLabel: 	        DB "MOS FLOPPY "
bsFileSystem: 	        DB "FAT12   "

;***************************************
;	Prints a string
;	DS=>SI: 0 terminated string
;***************************************

strTest: db "string", 0

Print:
			lodsb					; load next byte from string from SI to AL
			or			al, al		; Does AL=0?
			jz			PrintDone	; Yep, null terminator found-bail out
			mov			ah,	0eh	; Nope-Print the character
			int			10h
			jmp			Print		; Repeat until null terminator found
PrintDone:
			ret					; we are done, so return

;*************************************************;
;	Bootloader Entry Point
;*************************************************;

loader:

.Reset:
	mov		ah, 0					; reset floppy disk function
	mov		dl, 0					; drive 0 is floppy drive
	int		0x13					; call BIOS
	jc		.Reset					; If Carry Flag (CF) is set, there was an error. Try resetting again

	mov		ax, 0x1000				; we are going to read sector to into address 0x1000:0
	mov		es, ax
	xor		bx, bx

	mov		ah, 0x02				; read floppy sector function
	mov		al, 1					; read 1 sector
	mov		ch, 1					; we are reading the second sector past us, so its still on track 1
	mov		cl, 2					; sector to read (The second sector)
	mov		dh, 0					; head number
	mov		dl, 0					; drive number. Remember Drive 0 is floppy drive.
	int		0x13					; call BIOS - Read the sector
	
	jmp 0x1000:0x0
	
END:
	cli
	hlt


times 510 - ($-$$) db 0						; We have to be 512 bytes. Clear the rest of the bytes with 0

dw 0xAA55							; Boot Signiture

			mov			ah,	0eh	; Nope-Print the character
			mov         al,   't'
			int			10h
			
			cli
			hlt

This one doesn't work either. An yes I made sure to write more then 512 bytes to the image, and yes I double checked that with a hex editor. So what can be wrong with my bochs? I'm using Ubuntu 9.04. Here is my bochsrc

Code: Select all

# ROM and VGA BIOS images ---------------------------------------------

#romimage:    file=BIOS-bochs-latest, address=0xf0000 
#vgaromimage: VGABIOS-lgpl-latest 

# boot from floppy using our disk image -------------------------------

floppya: 1_44=../os/image-floppy.img, status=inserted  # Boot from drive A

# logging and reporting -----------------------------------------------

log:         OSDev.log             # All errors and info logs will output to OSDev.log
error:       action=report 
info:        action=report
Now that I come to think of it. This bochsrc is from brokenthorn but I had to comment out the first two lines because that bios was not installed. Maybe there is something wrong with the used bios?
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Help! did I load something?

Post by Troy Martin »

Maybe there is something wrong with the used bios?
The BIOS is fine. Your code, however, is not.

Seriously, take a step back, look over your code, read the intel manuals, and come back another day.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
Tjaalie
Member
Member
Posts: 25
Joined: Mon Mar 21, 2005 12:00 am

Re: Help! did I load something?

Post by Tjaalie »

This code is a strait copy from www.brokenthorn.com/Resources/OSDev5.html with the only expection being the code to display the char 't' to the screen (to indicate that where executing new code and not just halt the cpu).
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Help! did I load something?

Post by Troy Martin »

Well that's a problem, copying code without knowing what exactly it does. It takes ten to fifteen minutes to set up an assembly toolchain, five or ten to write a sector-based bootloader, and two to test it.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
Tjaalie
Member
Member
Posts: 25
Joined: Mon Mar 21, 2005 12:00 am

Re: Help! did I load something?

Post by Tjaalie »

I was actually writing my own bootloader (as you can see at the start of the thread), but because mine didn't work I tried the above one. But can you help me? I'm used to the gamedev.net forum where people are actually helping each other. There people criticise your code by actually explaining to you what's wrong and how to improve it, not just tell you to read a bunch of texts and leave.

Seriously, I might be bad at asm but I got a good gasp of C/C++ in a windows/linux environment if I may say so. I'm a total noob to os dev but I try to learn. If you don't want to help me, fine but than please don't respond to this thread and let people who actually want to help someone learn something talk.
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Re: Help! did I load something?

Post by 01000101 »

You know you're lacking in assembly knowledge, use GRUB(?)

Have you tried the bare-bones tutorial in the wiki?
Tjaalie
Member
Member
Posts: 25
Joined: Mon Mar 21, 2005 12:00 am

Re: Help! did I load something?

Post by Tjaalie »

When I boot with a image I found on the net (witch uses GRUB) it works. So does GRUB use int 0x13? If so then it must be my code. I will search for the GRUB source code to see if I can learn something from that.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Help! did I load something?

Post by neon »

Tjaalie wrote:This code is a strait copy from http://www.brokenthorn.com/Resources/OSDev5.html with the only expection being the code to display the char 't' to the screen (to indicate that where executing new code and not just halt the cpu).
Uhm.. no its not.

(Also, I do recommend not using the "demo" at the end of that tutorial - it is only meant as an example of use and can not be built as is...I need to update that soon... Try another tutorial and see what happens, please.)
#romimage: file=BIOS-bochs-latest, address=0xf0000
Most newer versions of bochs may give an error on the address line. Take the address=0xf0000 part out please. *sigh* Another thing I havnt updated yet, sorry #-o

Please explain the problem in more detail please. We might be able to help out better then :D
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Tjaalie
Member
Member
Posts: 25
Joined: Mon Mar 21, 2005 12:00 am

Re: Help! did I load something?

Post by Tjaalie »

I got it, somehow the way I tried to write out the contents of the memory failed, so it looked like there was nothing there!
Very very very stupid mistake that I will only make once in my life (I hope). I want to thank everyone one on this forum witch took the time to sit down and help this beginner with his problem. One day when I become a multi billionaire with my next windows like os I will buy you all a beer.

Tjaalie,
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Help! did I load something?

Post by Combuster »

Tjaalie wrote:One day when I become a multi billionaire with my next windows like os I will buy you all a beer.
I'll see you in the afterlife then, without beer :wink: (classic beginner mistake)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Tjaalie
Member
Member
Posts: 25
Joined: Mon Mar 21, 2005 12:00 am

Re: Help! did I load something?

Post by Tjaalie »

Combuster wrote:
Tjaalie wrote:One day when I become a multi billionaire with my next windows like os I will buy you all a beer.
I'll see you in the afterlife then, without beer :wink: (classic beginner mistake)
I could always sell my soul to :twisted: , it gets rid of those irritating boot loader bugs.
Post Reply