Well, Warrior got somewhere, I guess..
I've been slacking off on learning ASM, and frankly I want to learn it. Also, with learning PHP and Java, I should know enough of the common syntax to slack my way though a bit of C++, so here I go. I found some online tutorials, and I probably have the entire source code to OptimaOS seeing as how Warrior always lobs it at me over AIM (<3), so I'm gonna give it a shot. I've got my old Compaq Presario CDS 520, now named poptart (Thanks Ergot!) as a test box, because MS VPC hates me. I'll let you guys know how it goes.
EDIT -
I now understand why they said we'll be hitting our heads against the wall for the majority of the time. Where the fuck is Warrior?
Some powercord of his was being retarded and overheated randomly. He had to send in is faulty "modem" to get a new power cord. He'll be back soon.
Seriously? Because I just talked to him last night, and hes on AIM right now (not responding).
EDIT -
Well he was on earlier.
JoeOS rocks out loud. It doesn't do a single damned thing, but loop infinitly. It rocks!
[BITS 16] ;This tells us we are using 16 Bits
[ORG 0x7C00] ;We need to tell it the origin now
start:
jmp $
times 510-($-$$) db 0 ;This fills the rest of unused space with 0s
dw 0xAA55 ;Now our signature
Warrior's holding my hand through displaying "JoeOS" to the screen. So far we haven't even mastered the J yet. I mean, its displaying and all.. its just not.
[BITS 16] ;This tells us we are using 16 Bits
[ORG 0x7C00] ;We need to tell it the origin now
start:
xor ax, ax ; Make AX = 0
mov cs, ax ; Setup our registers
mov ds, ax ; Setup our registers
mov es, ax ; Setup our registers
mov fs, ax ; Setup our registers
mov ah, 0Eh
mov al, 'J'
mov bh, 0
mov bl, 0x07
int 10h
jmp $
times 510-($-$$) db 0 ;This fills the rest of unused space with 0s
dw 0xAA55 ;Now our signature
Uhm, what the hell? Why do all your comments say "we?" Do you program with a turd in your pocket? :D
He has been assimilated into the computer, your resistance is futile.
No, but Warriors holding my hand, in a non gay way. Hes giving me the comments to put in there anyhow. =).
EDIT -
I got my J.
(18:14:39) [x86] Warrior: OK U GOT A JAY
(18:15:45) [x86] Joe: YES I DID
(18:15:51) [x86] Joe: AND I GOT MY BRO TO COME LOOK AT IT!
(18:16:15) [x86] Joe: "Thats really really really gay!"
-----
Omg, it printed JoeOS to the screen. I am totally the worlds most awesomest hacker!
[BITS 16] ;This tells us we are using 16 Bits
[ORG 0x7C00] ;We need to tell it the origin now
start:
;xor ax, ax ; Make AX = 0
;mov cs, ax ; Setup our registers
;mov ds, ax ; Setup our registers
;mov es, ax ; Setup our registers
;mov fs, ax ; Setup our registers
mov ah, 0Eh
mov bh, 0
mov bl, 0x07
mov al, 'J'
int 10h
mov al, 'o'
int 10h
mov al, 'e'
int 10h
mov al, 'O'
int 10h
mov al, 'S'
int 10h
jmp $
times 510-($-$$) db 0 ;This fills the rest of unused space with 0s
dw 0xAA55 ;Now our signature
Now, when Warrior gets back from playing CS, I'm going to make it print colored strings!
That's a very crappy way of printing strings :P
You should also note that in the bootloader as I have told you before you are limited to 512 bytes in which you must load a second stage using the int 0x13 and read however many sectors you want to whatever location in the memory you want.
In the second stage you should prepare to enter protected mode: Enable the a20 line so that you can access the full 4GB in protected mode, setup atleast 3 GDT entries (Null, Code, Data), set the lower bit in cr0, then do a far jump to set CS. Once you're in protected mode you can either load an additional GDT (since the usefulness of your bootloader's GDT can be doubted for some reason) or use the one from before. Then you must handle request for Interrupts and distinguish which ones are exceptions and which are interrupts. This is done by setting up the IDT and handling ISRs. Once you have a *strong* exception handler (you can print registers). I'd work on polling port 0x60 every time you recieve IRQ6 (keybord) for the current character then using a scan code to convert it to ASCII. At this point you can either implement your own variant of "printf" and start implementing your library, or do what I did and setup a sort of driver manager to manage requests for notification of drivers.
Like so:
ServiceA(console) requests Keyboard Notification
ServiceB(someotherservice) requests Keyboard Notificiation
Keyboard IRQ Handler recieves interrupt:
Sends to all of the currently "registered" services for the Driver
Advantages of this: You don't have to have a lot of code in your IRQ handler, just something to dish out whatever needed.
Additionally having an app be able to request scancodes "on the go" using some sort of getkb(int num) to read each character and format it into a string then return when the number is met.
After this I'd implement a scheduler and maybe pre-emptive multitasking whichever then have some kernel level tasks working and swithing first before you move to User Level.
Anything after that is up to you:
Possibly some sort of VFS compatiblity layer? Maybe just run on to implementing something like NTFS or ext2?
Due to preference you may want to switch over to fasm which has basicly the same syntax of NASM but better error reporting and macros.
Your entire post went right over my head Warrior. Get back on AIM so we can take it nice and slow. Ugh, that sounds discusting. =p
EDIT -
I googled FASM. Am I looking for the flat assembler?
Yep.
Good. GET ON AIM!
*Hurrys up and tries to finish his asm book*
Shut up Sidoh. Lets see you write something better. Thanks for the input c0n, I'm trying to get that working. Warrior gave me some code, but its fucked up big time. He went to lay down, and I'm working with Darkness now.
Want your own copy of JoeOS?! Well, you're high. Anyhow, download this (http://www.javaop.com/~joe/joeos.zip), unzip it, and execute make. (You're going to need a floppy disk in fd0, probably a:).
Kernel was always easier for me provided I have a good exception handling system for my messups and a semi decent Library
c0n, you probably haven't knoticed yet, but Mangix is a moron who has trouble with VisualBasic. Anyone know whats wrong with the following code? It doesn't do jack shit except hang.
;-----------------------------------------------------------------------------------------
; These are my string constats. 0x01 is a smily face, 0x0D is a CR, 0x0A is a LF, and 0x00
; is a null terminator. Anything in quotes is the text of the string.
msgwelcome db "Welcome to JoeOS by Joe[x86]! ", 0x01, 0x0D, 0x0A, 0x00
msghalt db "Bootloader halted.", 0x0D, 0x0A, 0x00
msgshutdownsafe db "It is now safe to shutdown your computer.", 0x0D, 0x0A, 0x00
msgnewline db 0x0D, 0x0A, 0x00
; ----------------------------------------------------------------------------------------
; Here is the information that shows the processor where the origin of the bootloader is,
; and how many bits we're using.
[BITS 16] ; This tells us we are using 16 Bits
[ORG 0x0] ; Origin = 0x00
jmp 0x7c0:start ; Set start to 0x07C0 and start the procecdure "start" there
;-----------------------------------------------------------------------------------------
; This is my start procedure. This initiates the operating system environment, and calls
; my print procedure to display some messages
start:
xor ax, ax
mov ax, cs
mov ds, ax
mov es, ax
mov fs, ax
; Here I set the value of ax, ds, es, and fs to 0. I cant access these directly, so I xor
; ax to make it zero and move it to each of them.
mov si, msgwelcome
call print
; "Welcome to JoeOS by Joe[x86]! (smile)"
mov si, msghalt
callcprint
; "Bootloader halted."
mov si, msgshutdownsafe
call print
; "It is now safe to shutdown your computer."
jmp $ ; Hang
times 510-($-$$) db 0 ; This fills the rest of unused space with 0s
dw 0xAA55 ; Include bootloader signature
;-----------------------------------------------------------------------------------------
; Here is the print procedure I will be using. Written by Warrior[x86]. Broken. =/.
print:
mov ah, 0x10
mov bh, 0x00 ; Page = 0
mov bl, 0x09 ; Color = Blue
lodsb ; Load SI into AL
cmp al, 0 ; If we hit a null terminator..
je .Done ; Go to the label ".Done"
int 0x10 ; print the character
jmp print ; print until the whole string is printed
.Done: ; The label ".Done"
ret
EDIT -
OMG WTF I FOUND DEE PROBLEM IT IS 528 KB NOT 512 WTF HELP ME FIX IT WAR!~
If you want to tear me down, do it somewhere where I'm not a moderator. Get out of my forum or be positive towards my projects.
I'd think that the far jump would set the CS register *shrug* I lost my source so it's hard to tell what you're doing wrong.
You put your print procedure under the code that fills the rest with zeros so yes, you will step out of the 512 byte limit.
Smooth.
*cough* Ok. =).
Look up int 13h, you're going to want to have a second stage loaded soon
Have these IA-32 processors learned nothing of my stubbornness? Well, looks like they gave up. It works now. I don't have my working bootloader in the zip yet, because it takes forever to upload over SFTP, but download the zip and replace the bootloader.asm file with this (http://www.javaop.com/~joe/joeos/bootloader.asm) if you wanna check it out.
I made a JoeOS readme. Poke! (http://www.javaop.com/~joe/joeos/readme.txt) Check it out.
Are you testing on an old system or in something like VMWare or Bochs?
He has a test bed. Bochs is handy for it's useful debug messages and ability to emulate floppys, cdroms, etc.. and even has the ability to plug in additional BIOS's. Oh yea it's open source. 2.2 came out not too long ago :]
I just tried joes os. The coolest thing there was the smiley.
Zorm, I'm testing on a Compaq Presario CDS 520 (an old computer), and occasionally VirtualPC and my bros Dell Dimension 2300.
Warrior, I never got Bochs to work, but I have it installed. VPC likes to kill my modem driver. Wanna help me get Bochs to work? Thanks!
Damn right, Blaze. Go Palio! Oh wait, did I just agree with being torn down? Pfft, you suck Blaze! <3.
I have successfully loaded my pre-kernel from my floppy disk, so I am out of developming my bootloader, and am no longer restricted by Real Mode and the 512K bootloader limit. I should be able to enter Protected Mode and load a kernel now, however I'll save that for tomorrow. Aparently I've passed c0n at OS development, and thats enough for the first two days, if you ask me. I'm going to bed, cya tomorrow Warrior.
Quote[15:25:22] <Joe[x86]2> wtf
[15:25:24] <Joe[x86]2> well
[15:25:30] <Joe[x86]2> It loads stage 1 just fine
[15:25:37] <Joe[x86]2> attempts to load stage two
[15:25:38] <Joe[x86]2> and does
[15:25:39] <Joe[x86]2> and
[15:25:49] <Joe[x86]2> stage two prints its welcome message.. *counts*
[15:25:57] <Joe[x86]2> 10 fucking times
Oh man, I need to cut myself. I've done a lot of cutting myself lately. By the way, I hope you know I'm not serious about cutting myself. I haven't even hit my head against the wall yet.
Quote from: Joex86] link=topic=1636.msg14811#msg14811 date=1119129609]
Quote[15:25:22] <Joe[x86]2> wtf
[15:25:24] <Joe[x86]2> well
[15:25:30] <Joe[x86]2> It loads stage 1 just fine
[15:25:37] <Joe[x86]2> attempts to load stage two
[15:25:38] <Joe[x86]2> and does
[15:25:39] <Joe[x86]2> and
[15:25:49] <Joe[x86]2> stage two prints its welcome message.. *counts*
[15:25:57] <Joe[x86]2> 10 fucking times
Oh man, I need to cut myself. I've done a lot of cutting myself lately. By the way, I hope you know I'm not serious about cutting myself. I haven't even hit my head against the wall yet.
Keep at it and soon the problem will slap you in the face and be as obvious as the fact that you smell funny.
Shut up. You know I don't like people talking about my BO issue. =(
I already fixed it. I was ret'ing instead of jmp'ing.
Quote from: Joex86] link=topic=1636.msg14869#msg14869 date=1119199649]
You know I don't like people talking about my BO issue. =(
Well, its public now.
Quote from: Joex86] link=topic=1636.msg14869#msg14869 date=1119199649]
Shut up. You know I don't like people talking about my BO issue. =(
I already fixed it. I was ret'ing instead of jmp'ing.
;D I took a lucky guess.
Good job on figuring out the problem!
rofl you're such a retard joe.
It's just a joke, he doesn't have a BO problem. We're just trying to make people laugh!
Quote from: Tuberload on June 19, 2005, 04:49:57 PM
It's just a joke, he doesn't have a BO problem. We're just trying to make people laugh!
Then post a picture of your mom. Also Joe what advantage does JoeOS have over say Windows XP? I've been thinking of down-grading to the stone age but I don't know if you are there yet.
JoeOS is pre-stone age :p
Quote from: Nate on June 19, 2005, 05:39:23 PMThen post a picture of your mom.
Maybe you would get a laugh, superiority tends to make the jealous laugh in an attempt to keep their insecurities under wraps.
QuoteAlso Joe what advantage does JoeOS have over say Windows XP? I've been thinking of down-grading to the stone age but I don't know if you are there yet.
You're an idiot plain and simple.
yeah yeah, saying I was ahead was War's idea. =p
I screwed up my stage two loading, but I can fix it.. later!
As a joke and wasn't meant to go further than a joke
I know its been a while but i got bored and am trying some OSDev and ill probably start my own topic but in Warrior's print function that Joe uses 'mov ah, 0x10' makes absolutely no sense. Shouldn't it be 'mov ah, 0x0E' or maybe 'mov ah, 0x13'?
To be completely honest, I havn't looked at RBIL in a while so it may/may not be right. Of course anything I program is perfect so I'd say "Working as intended" unless of course..Joe managed to screw it up.
AH = 0Eh
AL = character to write
BH = page number
BL = foreground color (graphics modes only)
Function to print, untested
(WORD) Length of the string
(WORD) String Pointer
printf:
; Take in the arguments
pop ax ; String length
pop bx ; String pointer
; Set the interrupt arguments
mov ah, 0Eh
mov bh, 0
mov bl, 07h
xor cx, cx ; cx is counter, set to 0
.startloop
mv al, [bx+cx] ;[bx+cx] is the character to print
int 10h
cmp cx, ax
je .end
jmp startloop
.end
ret
Do you even know how printf() works? You'd need to implement stdarg.h and various functions to convert to different things like signed integers, unsigned integers, hex, etc..
Change the name from printf. It still prints a string.
I'm still not confortable using the stack before PMode, it's more to cleanup and the same could be acomplished by using the registers which are doing very little..
Quote from: Warriorx86] link=topic=1636.msg81813#msg81813 date=1153080339]
I'm still not confortable using the stack before PMode, it's more to cleanup and the same could be acomplished by using the registers which are doing very little..
You know, even DOS C libraries had printf. Psh.
Although, Joe, printf is named printf because it
prints a
formatted string....