flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Help to start my own OS Goto page 1, 2, 3, 4, 5, 6, 7 Next |
Author |
|
DOS386 13 May 2010, 02:04
> Can I have some help to start my own OS?
> I just like to do a simple OS with interface (windows What is your "OS" supposed to do ? http://wiki.osdev.org/Getting_Started#The_Hard_Truth http://wiki.osdev.org/Beginner_Mistakes I'm going to write more later Hint: bloat is your enemy in OS development (see attach)
|
||||||||||
13 May 2010, 02:04 |
|
Teehee 13 May 2010, 14:57
Hey, DOS.
DOS386 wrote: >What is your "OS" supposed to do ? well, i supposed to do a simple OS with all functionality which a OS must have. DOS386 wrote: http://wiki.osdev.org/Getting_Started#The_Hard_Truth Good text! DOS386 wrote: Hint: bloat is your enemy in OS development (see attach) What does bloat mean? are you refering to the img size? how do you get that? _________________ Sorry if bad english. |
|||
13 May 2010, 14:57 |
|
cod3b453 13 May 2010, 16:40
You can set up 32 bit protected mode with ring 0 only, VESA graphics and just the interrupts for a mouse driver fairly quickly but if you want "all the functionality" this is a lot bigger.
A good start is: - Intel and AMD manuals for system and application programming - Ralph Brown Interrupt List - Enabling A20 - Remapping PIC Good luck |
|||
13 May 2010, 16:40 |
|
Teehee 13 May 2010, 17:40
I have these boot file and 'hello world' kernel file:
boot.asm: Code: org 7C00h ; 07C0:0000 até 07C0:01FF --- Local onde foi carregado o bootloader ; 07C0:0200 até 07C0:03FF --- Pilha ; 0800:0000 em diante --- Kernel ;inicialização da pilha mov ax, 07C0h mov ss, ax mov sp, 03FEh ;aponta para o topo da pilha ;seta segmento de dados xor ax, ax mov ds, ax ;altera o modo de vídeo mov ah, 00h ;subfucao para setar modo de vídeo mov al, 03h ;03h = 80x25, 16 cores int 10h ;interrupt de vídeo ;le dados do disquete mov ah, 02h ;subfunção de leitura mov al, 1 ;numero de setores para ler mov ch, 0 ;trilha ( cylinder ) mov cl, 2 ;setor mov dh, 0 ;cabeça mov dl, 0 ;drive ( 00h = A: ) mov bx, 0800h ;ES:BX aponta para o local da memória_ mov es, bx ;onde vai ser escrito os dados mov bx, 0 ;0800:0000h ( ES = 0800h, BX = 0000h ) int 13h ;interrupt de disquete jmp 0800h:0000h ;pula para o local onde está o kernel ;e passa a execução para ele kernel.asm: Code: org 0000h push cs ;CS = endereço do programa atual pop ds ;DS = CS call clearscreen ;chama procedure de limpar a tela lea si, [Mensagem] ;SI = endereço da mensagem mov ah, 0Eh ;subfuncao para imprimir caractere loop: mov al, [si] ;move para AL o caractere em SI cmp al, 0h ;compara com 0 ( fim da string ) jz exit ;caso terminou, pule para ‘terminou’ int 10h ;interrupção de video inc si ;próximo caractere jmp loop ;repete o processo ate achar o 0 exit: mov ah, 0h ;subfuncao de aguardar tecla int 16h ;interrupção de teclado mov ax, 0040h ;método de reboot consiste em setar_ mov ds, ax ;o valor do endereço 0040:0072h_ mov word[0072h], 1234h ;para 1234h e pular para o endereço_ jmp 0FFFFh:0000h ;FFFF:0000h clearscreen: ;procedure de limpar a tela pusha ;coloca todos os reg na pilha mov ah, 06h ;subfuncao de rolar a tela pra cima mov al, 0 ;limpa a tela mov bh, 00001111b ;seta as cores ( fundo_texto ) mov ch, 0 ;linha do canto sup. esq. mov cl, 0 ;coluna do canto sup. esq. mov dh, 19h ;linha do canto inf. dir. ( 25 ) mov dl, 50h ;coluna do canto inf. dir. ( 80 ) int 10h ;interrupção de vídeo popa ;repõe os valores dos registradores ret ;retorna para o código Mensagem db 'Hello World from OS!',0 ;nossa string que vai ser exibida It's ok? can I start from here? if yes, how can I test it without restart my PC everytime? _________________ Sorry if bad english. |
|||
13 May 2010, 17:40 |
|
ManOfSteel 13 May 2010, 17:52
Teehee wrote: can I start from here? There's a beginning for everything... Teehee wrote: how can I test it without restart my PC everytime? http://bochs.sourceforge.net/ OR http://www.qemu.org/ |
|||
13 May 2010, 17:52 |
|
Teehee 13 May 2010, 18:31
If I understand i need to create a .img file, put it into a floppydisk and so bochs can emulate it. But how do i create the img file?
|
|||
13 May 2010, 18:31 |
|
cod3b453 13 May 2010, 18:59
You can also use VirtualBox or VMWare.
You can compile code to a disk image, luckily floppy disks are quite easy: Code: format binary as 'img' ; First sector (boot) org 0x7C00 ; Boot Sector code here ; Fill this sector up rb (0x7DFE - $) ; BIOS signature at end of boot sector dw 0xAA55 ; Second+ disk sector(s) org 0x8000 kernel: ; kernel code here ; Fill the disk image up (1.4Mb) times (0x0167E00 - ($ - kernel)) db 0 |
|||
13 May 2010, 18:59 |
|
Teehee 13 May 2010, 20:19
cod3b453, Woohoo!
_________________ Sorry if bad english. |
||||||||||
13 May 2010, 20:19 |
|
ManOfSteel 13 May 2010, 21:25
Or you can assemble separate files (but keep them sector aligned) and merge them using copy /b boot+kernel my_os.img.
|
|||
13 May 2010, 21:25 |
|
edfed 13 May 2010, 22:18
or you can assemble multiple files, and use HxD to write them where you want on a drive.
|
|||
13 May 2010, 22:18 |
|
Coddy41 14 May 2010, 01:02
nice Teehee, you might be interested in OS Devs "Baby Steps" since you've
made it that far might as well start on step 4 http://wiki.osdev.org/Babystep4 I for one thought they were handy I wish you luck |
|||
14 May 2010, 01:02 |
|
Teehee 14 May 2010, 22:56
Oh, so I can't use BIOS interrupts in Protected Mode?
well, i just need to know how to set Protected Mode. _________________ Sorry if bad english. |
|||
14 May 2010, 22:56 |
|
ManOfSteel 15 May 2010, 00:33
Teehee wrote: so I can't use BIOS interrupts in Protected Mode? Well, you can always switch between RM and PM and call BIOS interrupts while in RM, but it's not advisable and I would never talk about it myself. Ahem... Teehee wrote: i just need to know how to set Protected Mode edfed is such a nice person, he already wrote an example for you before you even asked. |
|||
15 May 2010, 00:33 |
|
Tyler 15 May 2010, 01:56
You should use grub. Here's a way to make a bootable floppy img when you compile.
Code: format binary as 'img' file '../precompiled grub/stage1' file '../precompiled grub/stage2' times 156 + 1024 db 0 ; You may need to change this to make sure you kernel is on a sector boundary include 'kernel.asm' ; If you want a non-flat binary kernel(elf, PE, or some other crap), compile it separately, and change include to file and the path to the path to the image times 1474560 + $$ - $ db 0 |
|||
15 May 2010, 01:56 |
|
Mac2004 15 May 2010, 06:58
Here's my example of loading plain binary file from a floppy disk. I'am
using partcopy to write the image on the floppy disk. http://board.flatassembler.net/topic.php?t=6529 regards, MAc2004 |
|||
15 May 2010, 06:58 |
|
Teehee 18 May 2010, 18:44
in PM i'm getting restart everytime. is it because I cannot use INT but i'm using it to print text and reading key to restart?
|
|||
18 May 2010, 18:44 |
|
baldr 18 May 2010, 19:45
Teehee wrote: in PM i'm getting restart everytime. is it because I cannot use INT but i'm using it to print text and reading key to restart? Can anybody explain to me, why would-be OS developers loathe real-address mode so much right from the start? Yes, segmentation issues can seem cumbersome and 1 MiB limitation looks goofy, but protected mode is way more complex to understand, much less to master. In return, RM offers friendly playground with rich APIs and almost unhindered freedom. |
|||
18 May 2010, 19:45 |
|
Teehee 18 May 2010, 22:22
Here my code:
image.asm: Code: format binary as 'img' ; First sector (boot) org 7C00h ; Boot Sector code include 'boot.asm' ; Fill this sector up rb (0x7DFE - $) ; BIOS signature at end of boot sector dw 0xAA55 ; Second+ disk sector(s) org 0000h kernel: ; kernel code include 'kernel.asm' ; Fill the disk image up (1.4Mb) times (0x0167E00 - ($ - kernel)) db 0 boot.asm: Code: ;org 7C00h ; 07C0:0000 até 07C0:01FF --- Local onde foi carregado o bootloader ; 07C0:0200 até 07C0:03FF --- Pilha ; 0800:0000 em diante --- Kernel ;inicialização da pilha mov ax, 07C0h mov ss, ax mov sp, 03FEh ;aponta para o topo da pilha ;seta segmento de dados xor ax, ax mov ds, ax ;altera o modo de vídeo mov ah, 00h ;subfucao para setar modo de vídeo mov al, 03h ;03h = 80x25, 16 cores int 10h ;interrupt de vídeo ;le dados do disquete mov ah, 02h ;subfunção de leitura mov al, 1 ;numero de setores para ler mov ch, 0 ;trilha ( cylinder ) mov cl, 2 ;setor mov dh, 0 ;cabeça mov dl, 0 ;drive ( 00h = A: ) mov bx, 0800h ;ES:BX aponta para o local da memória_ mov es, bx ;onde vai ser escrito os dados mov bx, 0 ;0800:0000h ( ES = 0800h, BX = 0000h ) int 13h ;interrupt de disquete ; set PM mode (Protected Mode) boot: cli lgdt [pmgdt] mov eax,cr0 inc ax mov cr0,eax mov ax,16 jmp 8:@f pmgdt: dw 23,pmgdt-3 db 0 dw 0ffffh,0,9a00h,0cfh dw 0ffffh,0,9200h,0cfh @@: jmp 0800h:0000h ;pula para o local onde está o kernel ;e passa a execução para ele kernel.asm: Code: use32 mov word[0b8000h],7441h ; print 'A' hlt @@: jmp @b For some reason I'm getting restart when I try to jump to kernel. _________________ Sorry if bad english. |
|||
18 May 2010, 22:22 |
|
edfed 18 May 2010, 23:06
Code: jmp 8:@f pmgdt: dw 23,pmgdt-3 db 0 dw 0ffffh,0,9a00h,0cfh dw 0ffffh,0,9200h,0cfh @@: ##############jmp 0800h:0000h############# you cannot jump to 800h:xxx that means jump to segment selector 800h in gdt. that is not what you want to do, forget about real mode, it is protected mode. you should do it: Code:
jmp 8000h
because CS is already at descriptor 8, that starts at 0 linear. then, your kernel is not org 0 but org 8000h you should provide a segment wich starts at 8000h to say, org 0, and do call segment8000h:0 |
|||
18 May 2010, 23:06 |
|
Goto page 1, 2, 3, 4, 5, 6, 7 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.