How I can Boot my Just-For-Fun OS from a Hard disk Drive?

sebastianfox

New Member
Hello, I'm 13 Years old and I'm a Nerd, because I'm interesting in programming. Now, I'm not stupid and don't think, that I just can write a Hello World Programm in BASIC. No, I can C, C++ and NASM. But a question asks me: I know, how I can make a bootable CD. But I don't know, how I can boot a OS from a Hard Disk Drive. I know, how from a Floppy Disk, but I dont know, how from a Hard Disk Drive. Did you know that?

PS: If my english is bad, please dont think, I'm stupid. I'm just a 13 Year old pupil from germany.
 
^ He's from Norway... :P

And actually, it's more random commas than verbs...your syntax is pretty good though.


I'm no programmer, but I think real mode operating systems are usually pretty tiny, aren't they? Seems like it'd be easier to use a flash drive...that process is pretty much the same as a floppy AFAIK.
 
No, the guy above you...gamerwithoutrig is form Norway. I was trying to point out that English probably isn't his first language either.

That thread was mostly beyond my level of knowledge, but I take it it's possible to use a flash drive? Cool! :)

I wish I could help with actually getting it onto a HDD :/
 
hmm....from a flash drive is a good idea, but i have some problems with my time value. here:

Code:
  mov ax, 0x07C0  ; set up segments
   mov ds, ax
   mov es, ax
 
   mov si, welcome
   call print_string
 
 mainloop:
   mov si, prompt
   call print_string
 
   mov di, buffer
   call get_string
 
   mov si, buffer
   cmp byte [si], 0  ; blank line?
   je mainloop       ; yes, ignore it
 
   mov si, buffer
   mov di, cmd_hi  ; "hi" command
   call strcmp
   jc .helloworld
 
   mov si, buffer
   mov di, cmd_help  ; "help" command
   call strcmp
   jc .help
   
   mov si, buffer
   mov di, cmd_word
   call strcmp
   jc .word
   mov si,badcommand
   call print_string 
   jmp mainloop  
 
 .helloworld:
   mov si, msg_helloworld
   call print_string
 
   jmp mainloop
 
 .help:
   mov si, msg_help
   call print_string
 
   jmp mainloop
 
 .word:
    mov ah, 7
    mov al, 0
    mov cl, 0
    mov ch, 0
    mov dh, 0
    mov dl, 0
    mov bh, 0x007
    int 10h
    mov ah, 2
    mov dh, 0
    mov dl, 0
    mov bh, 0
    int 10h
    call wstr
    jmp mainloop

jc .helloworld
 welcome db 'Braick OS v1.0, BETA 1, Codename Edox', 0x0D, 0x0A, 0
 msg_helloworld db 'Braick OS v1.0, BETA 1, Codename Edox', 0x0D, 0x0A, 0
 badcommand db 'Bad command', 0x0D, 0x0A, 0
 prompt db '>', 0
 cmd_hi db 'ver', 0
 cmd_help db 'help', 0
 msg_help db 'Commands: ver = version of OS; help = help for os commands', 0x0D, 0x0A, 0
 cmd_word db 'editor', 0x0D, 0x0A, 0
 buffer times 64 db 0
 
 print_string:
   lodsb        ; grab a byte from SI
 
   or al, al  ; logical or AL by itself
   jz .done   ; if the result is zero, get out
 
   mov ah, 0x0E
   int 0x10      ; otherwise, print out the character!
 
   jmp print_string
 
 .done:
   ret
 
 get_string:
   xor cl, cl
 
 .loop:
   mov ah, 0
   int 0x16   ; wait for keypress
 
   cmp al, 0x08    ; backspace pressed?
   je .backspace   ; yes, handle it
 
   cmp al, 0x0D  ; enter pressed?
   je .done      ; yes, we're done
 
   cmp cl, 0x3F  ; 63 chars inputted?
   je .loop      ; yes, only let in backspace and enter
 
   mov ah, 0x0E
   int 0x10      ; print out character
 
   stosb  ; put character in buffer
   inc cl
   jmp .loop
 
 
 strcmp:
 .loop:
   mov al, [si]   ; grab a byte from SI
   mov bl, [di]   ; grab a byte from DI
   cmp al, bl     ; are they equal?
   jne .notequal  ; nope, we're done.
 
   cmp al, 0  ; are both bytes (they were equal before) null?
   je .doe   ; yes, we're done.
 
   inc di     ; increment DI
   inc si     ; increment SI
   jmp .loop  ; loop!
 
 .notequal:
   clc  ; not equal, clear the carry flag
   ret
 
 .done: 	
   stc  ; equal, set the carry flag
   ret
 

 .backspace:
   cmp cl, 0	; beginning of string?
   je .loop	; yes, ignore the key
 
   dec di
   mov byte [di], 0	; delete character
   dec cl		; decrement counter as well
 
   mov ah, 0x0E
   mov al, 0x08
   int 10h		; backspace on the screen
 
   mov al, ' '
   int 10h		; blank character out
 
   mov al, 0x08
   int 10h		; backspace again
 
   jmp .loop	; go to the main loop
 
 .doe:
   mov al, 0	; null terminator
   stosb
 
   mov ah, 0x0E
   mov al, 0x0D
   int 0x10
   mov al, 0x0A
   int 0x10		; newline
 
   ret
 
 .save:
     mov bl, [di]
     mov ah, 3Ch
     mov cx, bl
     int 21h
     jmp mainloop
      wstr:
      xor cl, cl
 
 .loo:
   mov ah, 0
   int 0x16   ; wait for keypress
 
   cmp al, 0x09
   je .save
   
   cmp al, 0x08    ; backspace pressed?
   je .backspace   ; yes, handle it
 
   cmp al, 0x0D  ; enter pressed?
   je .don      ; yes, we're done
 
   cmp cl, 0x3F  ; 63 chars inputted?
   je .loo  ; yes, only let in backspace and enter
 
   mov ah, 0x0E
   int 0x10      ; print out character
 
   stosb  ; put character in buffer
   inc cl
   jmp .loo
   
   .don:
   mov al, 0	; null terminator
   stosb
 
   mov ah, 0x0E
   mov al, 0x0D
   int 0x10
   mov al, 0x0A
   int 0x10		; newline
 
   times 510-($-$$) db 0
   db 0x55
   db 0xAA

Times value is -8, also negative. can you tell me, what i have to do, that my os can starts?
 
Back
Top