this is the first source code of my o/s i ever posted.. it was originally posted on facebook.

this code doesnt work, but it will boot haha ---assembler with nasm use32 start: jmp code;

 

 

use32
start:
jmp code;
db 0 'dreamos ';
dw 512; ;bytes per sector
db 2 ;sectors per cluster
dw 0 ;reserved sectors
db 1 ;fats on disk
dw 1 ;root directory entries
dw 20 ;total sectors
db 11111110b ;media desciptor
dw 20 ;sectors per fat
dw 1 ;sectors per track
dw 2 ;heads
dw 0 ;hidden sectors
dd 0;
db 0; drive number
db 0;
db 29h;
dd 1;
db 'dreamos    ';
db 0,0,0,0,0,0,0,0;


our_section: db 0080 ;our section
try_again:
mov ah, 0x2;
mov al, 2;
mov ch, 0;
mov cl, 2;
mov dl, 0xa;
;lea es, our_section;
push our_section
pop es

mov bx, 0;
int 0x13;
jc code;
jmp try_again;


code:
push our_section;
pop es;
mov bx, 0;
mov cl, [bx];

cmp cl, 'N'
jne lets_exit





;print char
mov ah, 0x0a;
mov al, 'p';
mov bh, 0;
mov bl, 0;
mov cx, 8;
int 0x10;

mov ah, 0x00;
int 0x16;

;lea dx, string1;
lea ax, string1;

;mov offset,ax ;
jmp print;
offset dw $;
offset2 dw second_pause
;to call this, first push the offset of where you are in es:dx
;then push location of the string in a dw
;then finally push the segment of the string
print:
;pop es  ;segment of string
;pop dx  ;location in that segment
next:
mov ax, string1;
add ax, cx
cmp ax, '$';
jne continue_print;
jmp [offset2];
continue_print:
mov ah, 0x0a;
mov al, string1 + $offset;
mov bh, 0;
mov bl, 0;
mov cx, 1;
int 0x10;
jmp next
second_pause:
mov ah, 0x00;
int 0x16


jmp next;
string1: db 'hello world','$'

;base equ $-start
base2 equ 510-$;
after_code:
db base2 dup (0);
db 0x55;
db 0xaa;
next_sector:
jmp b_next_sector;
blah_sig:  db 'Nick';
b_next_sector:
base3 equ 1024-$;
db base3 dup (?);

lets_exit;

Comments

Popular posts from this blog

woo hoo, here is an easy way to make UEFI boot code for YOUR os :D

my latest os code, but its almost basically taken 95% from gemini. (i was on the right path, but i think my bad fat info ruined it)