Page 1 of 1

Just wondering... a couple basic personal questions...

Posted: Wed Aug 27, 2008 7:53 pm
by daBKLYNdoorman
Hey guys,

This is my first post here at OS-Dev and thank God I found this forums. Let me begin by introducing myself. My name is Robert, I'm 17 years old, I'm from New York City, and I go to high school. Just like most if not all of you, I'm interested in OS development and the ability to make something work after months (or years) of hard work.

A few weeks ago, I started reading the tutorials from BrokenThorn Entertainment (google that, go to development tutorials), and I wrote my own bootloader. I'm reading the PCASM (PC Assembly Language) online book to learn more about assembly language. As for programming languages, I've been studying Java and some basic C++ for about a year.

Now the thing is, I'd like to know how you people started OS deving and what got you interested in it in the first place. Like, how long did it take you to learn assembly language, how you learned it, etc. Just stuff like that and any suggestions you have for a beginner like me.

Thanks a lot,
Robert

Re: Just wondering... a couple basic personal questions...

Posted: Wed Aug 27, 2008 8:20 pm
by Alboin
Now the thing is, I'd like to know how you people started OS deving and what got you interested in it in the first place.
It was so long ago, I don't much remember. IIRC, however, I started writing a windows shell one day and realized that the EXE would not boot off a floppy disk. [-X
Like, how long did it take you to learn assembly language, how you learned it
I read the book you mentioned, and kind of worked with it from there. I've never had a lot of difficulty with assembly.

In osdev, you have three lovers: the Intel Manuals, the. Programming Language, and the Tool Chain. None of them are jealous of the others, and, interestingly enough, are quite pleasant with one another. Get to know them intimately.

Re: Just wondering... a couple basic personal questions...

Posted: Wed Aug 27, 2008 8:32 pm
by Omega
Hi. I think most of the mods are real-world system engineers/software engineers and they have probably learned their skills either on their own or in class, perhaps both. I myself taught myself. I am a second year CS major and I am just now taking my second Computer Course which relates with my minor and isn't even a programming class, my first one was JAVA. I just started at the bottom (or top) with HTML/JavaScript (web stuff), then I moved to VB (strict Windows user) and then C/C++, then ASM. I just wrote things I wanted to write and that made it both fun and rewarding, so I learned very fast. I wrote many things, and I always made sure they were big. I got my speed up and after... what is it now... 7 years? I thought OK lets go real big and dev an OS. It is very challenging work and even with 7 years I do not feel like I am completely worthy most of the time, some days I do though (when I make something work mainly). You have a long road ahead of you. I hope you stay committed to trying, because you will fail many times and it will seem like your moving backwards. It took me 5 months to make the keyboard respond, the keyboard!! I am fortunate to be as far as I am now (writing a sil3112 driver, thus denoting my near completion) in 6 months. My secret is:

01. I am totally an utterly obsessed with getting it done so much that I put in a lot of my time working on it... more than work or class, which is bad.
02. I stand upon the shoulders of giants and I port a lot of ideas. I try to stay away from Linux code, but I have looked at some things to see how they did it, such as the KB Shift Map.. I didn't use it, but I saw what to do and made my own (still very much different).

The fact that I write pretty well in C has helped a lot too. I suck at ASM, but I hold my own. My kernel is written in C with few ASM components; my HAL is in ASM. So, since C is more readable I would suggest that to you, but it doesn't hurt to know ASM better.

Check out Ralph Brown's INT list and that should help you get to know the functions you will use better. Write some hello world stuff and tweak it many different ways. Try to write the same program in C or C++ and that will help you with inline and also conversions from ASM to C. Get a manual of your compiler, Linker, and Assembler, you may need it.

And, because its your UN-Birthday (maybe your birthday) AND I want you to be successful, here is a starting point:

Code: Select all

;//FREE CODE, I DON'T F-ING CARE WHAT YOU DO WITH IT!! ENJOY AND HAPPY LEARNING!!

[BITS 16]       ; We start the setup in Rmode

[ORG 0x7C00]    ; The BIOS loads the boot sector into memory location 0x7C00
		
		;*******************************
		; Step 1: Load our Kernel into memory
		;*******************************
reset_drive:
        mov ah, 0               ; RESET-command
        int 13h                 ; Call interrupt 13h
        or ah, ah               ; Check for error code
        jnz reset_drive         ; Try again if ah != 0

        mov ax, 0
        mov es, ax
        mov bx, 0x1000          ; We load our code at offset: 0:1000h

        mov ah, 02h             ; READ SECTOR-command
        mov al, 11h             ; Number of sectors to read
        mov ch, 0               ; Cylinder = 0
        mov cl, 02h             ; Sector = 2
        mov dh, 0               ; Head = 0
        int 13h                 ; Call interrupt 13h
        or ah, ah               ; Check for error code
        jnz reset_drive         ; Try again if ah != 0
		
.386    ; start using i386 instructions
		
		;*******************************
        ; Step 2: Enable the A20 bus line
		;*******************************
        cli						;disable interrupts
		xor cx, cx				;clear the CX register
clear_buf:
        in al, 64h              ; Get input from keyboard status port
        test al, 02h            ; Test the buffer full flag
        loopnz clear_buf        ; Loop until buffer is empty
        mov al, 0D1h            ; Keyboard: write to output port
        out 64h, al             ; Output command to keyboard
clear_buf2:
        in al, 64h              ; Wait 'till buffer is empty again
        test al, 02h
        loopnz clear_buf2
        mov al, 0dfh            ; Keyboard: set A20
        out 60h, al             ; Send it to the keyboard controller
        mov cx, 14h
wait_kbc:                       ; This is approx. a 25uS delay to wait
        out 0edh, ax            ; for the kb controler to execute our 
        loop wait_kbc           ; Command.
		
		;*******************************
		; Step 3: Enable GDT for Pmode
		;*******************************
		xor ax, ax
        mov ds, ax              ; Set DS-register to 0 - used by lgdt
        lgdt [gdt_desc]         ; Load the GDT descriptor

		;*******************************
		; Step 4: Clear Prefetch Queue
		;*******************************
        mov eax, cr0            ; Load the control register in
        or  al, 1               ; Set bit 1: pmode bit
        mov cr0, eax            ; Copy it back to the control register
		
		;*******************************
		; Step 5: Enable Pmode
		;*******************************
        jmp 08h:PModeMain      	; Jump to code segment; Start Pmode

[BITS 32]                       ; We now need 32-bit instructions
PModeMain:
        mov ax, 10h             ; Save data segment identifyer
        mov ds, ax              ; Move a valid data segment into the data segment register
        mov ss, ax              ; Move a valid data segment into the stack segment register
        mov esp, 090000h        ; Move the stack pointer to 090000h

		;*******************************
		; Step 6: Boot our Kernel
		;*******************************
        jmp 08h:01000h          ; Jump to section 08h (code), offset 01000h
		
;***********************************
;Configurations Section, DO NOT EDIT!!
;***********************************
gdt:                    ; Address for the GDT

gdt_null:               ; Null Segment
        dd 0
        dd 0

gdt_code:               ; Code segment, read/execute, nonconforming
        dw 0FFFFh
        dw 0
        db 0
        db 10011010b
        db 11001111b
        db 0

gdt_data:               ; Data segment, read/write, expand down
        dw 0FFFFh
        dw 0
        db 0
        db 10010010b
        db 11001111b
        db 0

gdt_end:                ; Used to calculate the size of the GDT

gdt_desc:                       ; The GDT descriptor
        dw gdt_end - gdt - 1    ; Limit (size)
        dd gdt                  ; Address of the GDT

times 510-($-$$) db 0           ; Fill up the file with zeros

        dw 0AA55h                ; Boot sector identifyer
Don't think I am leaving you hanging without the link info:

Code: Select all

@echo off

::**********************
::Change path to project folder
::**********************
set PATH=c:\djgpp\bin;%PATH%
set DJGPP=c:\djgpp\djgpp.env
chdir C:\djgpp\toy os\src

::***************
::Assemble OS Loader
::***************
nasm -f coff loader.asm -o loader.o

::******************
::Compile/Assemble Kernel
::******************
c:\djgpp\bin\gcc -ffreestanding -c main.c -o main.o

::**************
::Link it all together
::**************
c:\djgpp\bin\ld -Map kernel.sym -T 0x1000 -o kernel loader.o main.o
Something like that. Check your LD Manual for this... it may not be -T (I use a real LINK file in my OS); sorry.

OK. This will need GCC||DJGPP, LD, and NASM.

Side effects are: Once your OS gets bigger than 18 sectors your screwed and will need a second stage or GRUB to continue safely. Now get coding. :)

P.s. I hope no one gets upset with me helping so much; I believe in examples; sorry.

Re: Just wondering... a couple basic personal questions...

Posted: Wed Aug 27, 2008 9:16 pm
by piranha
I wanted to be in full control, so I chose OSdev.
Like, how long did it take you to learn assembly language, how you learned it
I never actively learned it. I just read some stuff, and went from there. I have only a basic understanding of ASM.

Good luck with your os and welcome to the forums.

-JL

Re: Just wondering... a couple basic personal questions...

Posted: Wed Aug 27, 2008 9:21 pm
by cr2
Should this thread be moved??

Re: Just wondering... a couple basic personal questions...

Posted: Wed Aug 27, 2008 10:42 pm
by 01000101
cr2 wrote:Should this thread be moved??
It is OS Development related and is probably not generalized enough to be placed in the other non-specific forums.

I got into OS development as a personal challenge, coding hosted applications gets repetitive and unrewarding after a while. I started off with C, and coding a basic kernel that was booted from GRUB. I later decided that I wanted to make an OS that could become a tool for sysadmins, so I began recoding everything (including my own bootloader). I picked up assembly in an 'on demand' fashion, only acquiring specific details to help me a little further in the code, it wasn't until much later that I really began to grasp the real workings of the assembly language. After reading the Intel manuals from (nearly 8) ) cover to cover, and re-reading sections probably hundreds of times, I can safely say that my understanding of operating systems is significantly greater than that of my former coding self. I also have a fascination with the inner-workings of the internet (packet-level inspection), and this is another reason I decided to choose the low-level coding route. As stated above, control was another factor.

Assembly language is not hard to learn syntactically, but developing a proper understanding of the concepts governing the language is what it's all about; this applies to most mid-low level languages.

Re: Just wondering... a couple basic personal questions...

Posted: Thu Aug 28, 2008 11:13 am
by Dex
I start learning ASM because when trying to make a pascal OS, i needed to use a lot of inline assembly.
I got to like it so much that i decided to code it fully in ASM.
To help me learn about OS and learn ASM at the same time, i started to code bootable demos, like games, cdplayers etc, i just moved on from there, but the best and only way to learn ASM is to try and code something every day, at first it will seem hard, but it gets easier, and remember we are all still learning all the time.

Re: Just wondering... a couple basic personal questions...

Posted: Thu Aug 28, 2008 7:08 pm
by AndrewAPrice
I first learnt QBasic when I was 10 (or maybe earlier but I don't remember), I started with C++ around 13, and C# around 15. I touched my first assembly at the same time, though I wouldn't call myself an expert at it :)

Re: Just wondering... a couple basic personal questions...

Posted: Thu Aug 28, 2008 7:53 pm
by PatrickV
I am still learning my self. :D

Re: Just wondering... a couple basic personal questions...

Posted: Sat Aug 30, 2008 8:55 pm
by thepowersgang
I started with osdev because I was curious/sick of windows, but it took a while to learn.

I started with Bran's Kernel Dev tutorial and just worked through that. (Now that i think of it I think that some parts of my OS are still almost unchanged from his code... :| )

Re: Just wondering... a couple basic personal questions...

Posted: Sun Aug 31, 2008 2:29 am
by RevivalDBM
I started OSDev a while ago - by making an alternative window manager for windows, that could run programs outside of windows written in a script form I made - I wanted to make it a full OS however, and knew that if I worked long and hard enough, an OS of my own could have many features, whilst also being a learning experiance. So, I headed to Bran's Kernel Dev tutorial, followed it through, failed to compile. I found the OSDev wiki, and the barebones tutorials got me a bootable kernel, and then, I followed James Molloy's tutorials, which were some of the best I'd read, and taught me a lot, and with the knowledge I gained, I started an OS made by me a few weeks ago.

Re: Just wondering... a couple basic personal questions...

Posted: Sun Aug 31, 2008 3:38 am
by PHPnerd
I'm always looking for more difficult programs, applications, etc, to make. Some day, i found OSdeving.

And i didn't learn ASM.

// PHPnerd