initial
This commit is contained in:
commit
67a9e37c5c
|
@ -0,0 +1,2 @@
|
|||
tmp/
|
||||
.project
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
#add build-nr
|
||||
build=$(cat build)
|
||||
sed "s/######/${build}/g" src/main.asm > tmp/main.asm
|
||||
build=$((build+1))
|
||||
echo $build > build
|
||||
echo "Build-Nummer aktualisiert.";
|
||||
#compile
|
||||
echo "Wandle boot.asm in boot.bin um...";
|
||||
nasm src/boot.asm -o tmp/boot.bin
|
||||
echo "Fertig.";
|
||||
echo "Wandle main.asm in main.bin um...";
|
||||
nasm tmp/main.asm -o tmp/main.bin
|
||||
echo "Fertig.";
|
||||
|
||||
|
||||
#connect
|
||||
echo "Erstelle .img Image...";
|
||||
cat tmp/boot.bin tmp/main.bin > out/os.img
|
||||
|
||||
echo "Vorgang beendet";
|
||||
virtualbox --startvm own
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
#add build-nr
|
||||
build=$(cat build)
|
||||
sed "s/######/${build}/g" src/main.asm > tmp/main.asm
|
||||
build=$((build+1))
|
||||
echo $build > build
|
||||
|
||||
|
||||
#compile
|
||||
nasm src/boot.asm -o tmp/boot.bin
|
||||
nasm tmp/main.asm -o tmp/main.bin
|
||||
|
||||
#connect
|
||||
cat tmp/boot.bin tmp/main.bin > out/os.img
|
||||
|
||||
sh run.sh
|
|
@ -0,0 +1,7 @@
|
|||
all:
|
||||
build=$(cat build)
|
||||
sed 's/######/${build}/g' src/main.asm > tmp/main.asm
|
||||
nasm src/boot.asm -o tmp/boot.bin
|
||||
nasm tmp/main.asm -o tmp/main.bin
|
||||
cat tmp/boot.bin tmp/main.bin > out/os.img
|
||||
virtualbox --startvm own
|
|
@ -0,0 +1,35 @@
|
|||
Notes:
|
||||
|
||||
|
||||
-------------------------
|
||||
Ziele:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------
|
||||
Nachrichten:
|
||||
--------------------------
|
||||
An Besen:
|
||||
|
||||
|
||||
--------------------------
|
||||
An Thiesyy:
|
||||
--------------------------
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,77 @@
|
|||
org 0x7C00 ; set up start address
|
||||
|
||||
; setup a stack
|
||||
mov ax, 0x9000 ; address of the stack SS:SP
|
||||
mov ss, ax ; SS = 0x9000 (stack segment)
|
||||
xor sp, sp ; SP = 0x0000 (stack pointer)
|
||||
|
||||
; start
|
||||
mov [bootdrive], dl ; boot drive from DL
|
||||
call load_kernel ; load kernel
|
||||
|
||||
; jump to kernel
|
||||
jmp 0x1000:0x0000 ; address of kernel
|
||||
|
||||
bootdrive db 0 ; boot drive
|
||||
loadmsg db "loading kernel ...",0
|
||||
|
||||
; print string
|
||||
print_string:
|
||||
lodsb ; grab a byte from SI
|
||||
or al, al ; NUL?
|
||||
jz .done ; if the result is zero, get out
|
||||
mov ah, 0x0E
|
||||
int 0x10 ; otherwise, print out the character!
|
||||
jmp print_string
|
||||
.done:
|
||||
ret
|
||||
|
||||
|
||||
; read kernel from floppy disk
|
||||
load_kernel:
|
||||
|
||||
mov dh, 10 ;row
|
||||
mov dl, 28 ;colum
|
||||
mov bh, 0 ;page
|
||||
mov ah, 2 ;interupt selection
|
||||
int 10h ;coursor to middle
|
||||
|
||||
;hide coursor
|
||||
mov ch, 32
|
||||
mov ah, 1
|
||||
int 10h
|
||||
|
||||
|
||||
mov si,loadmsg
|
||||
call print_string ;welcome message
|
||||
|
||||
MOV CX, 0FH
|
||||
MOV DX, 4240H
|
||||
MOV AH, 86H
|
||||
INT 15H;wait interupt
|
||||
|
||||
mov dl,[bootdrive] ; select boot drive
|
||||
xor ax, ax ; mov ax, 0 => function "reset"
|
||||
int 0x13
|
||||
jc load_kernel ; trouble? try again
|
||||
|
||||
load_kernel1:
|
||||
mov ax, 0x1000
|
||||
mov es, ax ; ES:BX = 0x10000
|
||||
xor bx, bx ; mov bx, 0
|
||||
|
||||
; set parameters for reading function
|
||||
; 8-Bit-wise for better overview
|
||||
mov dl,[bootdrive] ; select boot drive
|
||||
mov al,10 ; read 10 sectors
|
||||
mov ch, 0 ; cylinder = 0
|
||||
mov cl, 2 ; sector = 2
|
||||
mov dh, 0 ; head = 0
|
||||
mov ah, 2 ; function "read"
|
||||
int 0x13
|
||||
jc load_kernel1 ; trouble? try again
|
||||
ret
|
||||
|
||||
times 510-($-$$) hlt
|
||||
db 0x55
|
||||
db 0xAA
|
|
@ -0,0 +1,55 @@
|
|||
void k_clear_screen() {
|
||||
char* vidmem = (char*) 0xb8000;
|
||||
unsigned int i=0;
|
||||
while(i<(80*2*25)) {
|
||||
vidmem[i] = ' ';
|
||||
++i;
|
||||
vidmem[i] = 0x07;
|
||||
++i;
|
||||
};
|
||||
};
|
||||
|
||||
unsigned int k_printf(char* message, unsigned int line) {
|
||||
char* vidmem = (char*) 0xb8000;
|
||||
unsigned int i = line*80*2;
|
||||
|
||||
while(*message!=0) {
|
||||
if(*message==0x2F) {
|
||||
*message++;
|
||||
if(*message==0x6e) {
|
||||
line++;
|
||||
i=(line*80*2);
|
||||
*message++;
|
||||
if(*message==0){return(1);};
|
||||
};
|
||||
};
|
||||
vidmem[i]=*message;
|
||||
*message++;
|
||||
++i;
|
||||
vidmem[i]=0x7;
|
||||
++i;
|
||||
};
|
||||
return 1;
|
||||
};
|
||||
|
||||
inline void outportb(unsigned int port,unsigned char value) {
|
||||
asm volatile ("outb %%al,%%dx"::"d" (port), "a" (value));
|
||||
};
|
||||
|
||||
void update_cursor(int row, int col) {
|
||||
unsigned short position=(row*80) + col;
|
||||
// cursor LOW port to vga INDEX register
|
||||
outportb(0x3D4, 0x0F);
|
||||
outportb(0x3D5, (unsigned char)(position&0xFF));
|
||||
// cursor HIGH port to vga INDEX register
|
||||
outportb(0x3D4, 0x0E);
|
||||
outportb(0x3D5, (unsigned char)((position>>8)&0xFF));
|
||||
};
|
||||
|
||||
int _main() {
|
||||
k_clear_screen();
|
||||
k_printf("Welcome to ThiesyyOS.", 0);
|
||||
k_printf("The C kernel has been loaded.", 2);
|
||||
update_cursor(3, 0);
|
||||
return 0;
|
||||
};
|
Binary file not shown.
|
@ -0,0 +1,8 @@
|
|||
OUTPUT_FORMAT("binary")
|
||||
ENTRY(RealMode)
|
||||
SECTIONS
|
||||
{
|
||||
.text 0x8000 : { *(.text) }
|
||||
.data : { *(.data) }
|
||||
.bss : { *(.bss) }
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,323 @@
|
|||
|
||||
mov ax, 0x1000 ; set up segments
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
call clrscr ;clear screen
|
||||
|
||||
;mov si, logo
|
||||
;call print_string
|
||||
|
||||
mov si, logo
|
||||
call print_string
|
||||
mov si, welcome ;welcome message
|
||||
call print_string
|
||||
mov si, build; build nummber
|
||||
call print_string
|
||||
;call setupMouse
|
||||
|
||||
loop:
|
||||
;call drawMousePixel
|
||||
;jmp loop
|
||||
|
||||
mov si, prompt
|
||||
call print_string
|
||||
|
||||
mov di, buffer
|
||||
call get_string
|
||||
|
||||
mov si, buffer
|
||||
cmp byte [si], 0 ; blank line?
|
||||
je loop ; yes, ignore it
|
||||
|
||||
mov si, buffer
|
||||
mov di, cmd_hi ; "hi" command
|
||||
call strcmp
|
||||
jz .helloworld
|
||||
|
||||
mov si, buffer
|
||||
mov di, cmd_help ; "help" command
|
||||
call strcmp
|
||||
jz .help
|
||||
|
||||
mov si, buffer
|
||||
mov di, cmd_credits ; "credits" command
|
||||
call strcmp
|
||||
jz .credits
|
||||
|
||||
mov si, buffer
|
||||
mov di, cmd_beep ; "beep" command
|
||||
call strcmp
|
||||
jz .beep
|
||||
|
||||
mov si, buffer
|
||||
mov di, cmd_reboot ; "reboot" command
|
||||
call strcmp
|
||||
jz .reboot
|
||||
|
||||
mov si, buffer
|
||||
mov di, cmd_halt ;"halt command
|
||||
call strcmp
|
||||
jz .halt
|
||||
|
||||
mov si, buffer
|
||||
mov di, cmd_banner ;"banner command
|
||||
call strcmp
|
||||
jz .banner
|
||||
|
||||
mov si,badcommand ; "failed"
|
||||
call print_string
|
||||
jmp loop
|
||||
|
||||
.helloworld:
|
||||
mov si, msg_helloworld
|
||||
call print_string
|
||||
|
||||
jmp loop
|
||||
|
||||
.help:
|
||||
mov si, msg_help
|
||||
call print_string
|
||||
|
||||
jmp loop
|
||||
|
||||
.credits:
|
||||
mov si, msg_credits
|
||||
call print_string
|
||||
|
||||
jmp loop
|
||||
|
||||
.banner:
|
||||
mov si, logo
|
||||
call print_string
|
||||
|
||||
jmp loop
|
||||
|
||||
.beep:
|
||||
mov si, beep_code
|
||||
call print_string
|
||||
|
||||
jmp loop
|
||||
|
||||
.reboot:
|
||||
mov si, msg_reboot
|
||||
call print_string
|
||||
int 19h ;welches man nimmt ist egal
|
||||
;jmp 0xffff:0x0000
|
||||
|
||||
.halt:
|
||||
mov si, msg_halt
|
||||
call print_string
|
||||
|
||||
mov ax, 0x1000
|
||||
mov ax, ss
|
||||
mov sp, 0xf000
|
||||
mov ax, 0x5307
|
||||
mov bx, 0x0001
|
||||
mov cx, 0x0003
|
||||
int 0x15
|
||||
|
||||
|
||||
clrscr:
|
||||
mov ax, 0x0600
|
||||
xor cx, cx
|
||||
mov dx, 0x174F
|
||||
mov bh, 0x07
|
||||
int 0x10;clear screen interupt
|
||||
call resetcoursor
|
||||
ret
|
||||
|
||||
resetcoursor:;resets the coursor position
|
||||
mov dh, 0 ;row
|
||||
mov dl, 0 ;cloum
|
||||
mov bh, 0 ;page
|
||||
mov ah, 2 ;interupt select
|
||||
int 10h ;interupt
|
||||
|
||||
;set coursor visible
|
||||
mov ch, 6;oder 0 je nach form
|
||||
mov cl ,7;bottom coursor line
|
||||
mov ah, 1;interupt select
|
||||
int 10h;interupt
|
||||
ret
|
||||
;SETUP MOUSE
|
||||
setupMouse:
|
||||
MOV AX,01
|
||||
INT 33h
|
||||
|
||||
INT 21h
|
||||
|
||||
|
||||
;setupMouse:
|
||||
; mov ax, 0
|
||||
; int 33h;init mouse
|
||||
; mov ax, 1
|
||||
; int 33h;show mouse pointer
|
||||
; ret
|
||||
|
||||
;setup graphix
|
||||
;mov al, 13h; graphic mode; 00h- text mode. 40x25. 16 colors. 8 pages. 03h- text mode. 80x25. 16 colors. 8 pages. 13h - graphical mode. 40x25. 256 colors. 320x200 pixels. 1 page.
|
||||
;mov ah, 0
|
||||
;int 10h;INIT GRAPHIX
|
||||
;ret
|
||||
|
||||
;drawMousePixel:
|
||||
;mov ax, 0
|
||||
;int 33h;init mouse
|
||||
;mov al, 1100b;color
|
||||
|
||||
;grab mouse
|
||||
;mov ax, 3
|
||||
;int 33h;get mouse cords
|
||||
;mov [x], cx
|
||||
|
||||
;mov ax, dx
|
||||
;mov dx, 320
|
||||
;mul dx; multiply ax(y) with 320
|
||||
|
||||
;mov dx, ax
|
||||
|
||||
; mov cx, [x]
|
||||
; mov dx, [y]
|
||||
; mov ah, 0ch; interuption select
|
||||
; int 10h; interupt
|
||||
; ret
|
||||
|
||||
welcome db 'Welcome to ThiesyyyOS! build ', 0
|
||||
build db '######', 0x0D, 0x0A, 0
|
||||
beep_code db 0x07, 0
|
||||
|
||||
badcommand db 'Computer says: no', 0x0D, 0x0A, 0
|
||||
prompt db '-> ', 0
|
||||
|
||||
cmd_reboot db 'reboot', 0
|
||||
cmd_credits db 'credits', 0
|
||||
cmd_hi db 'hi', 0
|
||||
cmd_help db 'help', 0
|
||||
cmd_beep db 'beep', 0
|
||||
cmd_halt db 'stop', 0
|
||||
cmd_banner db 'banner', 0
|
||||
|
||||
msg_halt db 'Stopping....', 0
|
||||
msg_reboot db 'Rebooting....',0
|
||||
msg_helloworld db 'Hey, Man!', 0x0D, 0x0A, 0
|
||||
msg_help db 'ThiesyyyOS Commands:', 0x0D, 0x0A ,'hi', 0x0D,0x0A,'help', 0x0D, 0x0A,'credits', 0x0D,0x0A,'beep[WIP]',0x0D,0x0A,'reboot',0x0D,0x0A,'stop', 0x0D, 0x0A, 0
|
||||
msg_credits db 'Developed and Tested by Thiesyyy and MrBesen!', 0x0D, 0x0A, 0
|
||||
|
||||
;logo db ' _______ _ _ _ _____ ____ ___ __ ___ __ ___ __ ______ ____ ',0x0D,0x0A, '|__ __| | | | | |_| | ____| / ____| \ \ / / \ \ / / \ \ / / | ___ | / ____| ',0x0D,0x0A, ' | | | |__| | _ | |___ | / \ \/ / \ \/ / \ \/ / | | | | | / ',0x0D,0x0A, ' | | | __ | | | | ___| \ \ \ / \ / \ / | | | | \ \ ',0x0D,0x0A, ' | | | | | | | | | | \ \ \ / \ / \ / | | | | \ \ ',0x0D,0x0A, ' | | | | | | | | | |___ _\ \ | | | | | | | |___| | _\ \ ',0x0D,0x0A, ' |_| |_| |_| |_| |_____| |_____/ |_| |_| |_| |_______| |_____/ ',0x0D,0x0A, 0
|
||||
logo db ' ____________________________________________________________________', 0x0d, 0x0A, '| |', 0x0D, 0x0A, '| ThiesyyyOS |',0x0D,0x0A,'| |', 0x0D, 0x0A, '|____________________________________________________________________|',0x0D,0x0A,0
|
||||
|
||||
buffer times 64 db 0
|
||||
; _
|
||||
; |_|
|
||||
;
|
||||
|
||||
;_|_|_|_|_| _| _|
|
||||
; _| _|_|_| | _|_| _|_|_| _| _| _| _| _|_| _|_|_|
|
||||
; _| _| _| _| _|_|_|_| _|_| _| _| _| _| _| _| _|_|
|
||||
; _| _| _| _| _| _|_| _| _| _| _| _| _| _|_|
|
||||
; _| _| _| _| _|_|_| _|_|_| _|_|_| _|_|_| _|_| _|_|_|
|
||||
; _| _|
|
||||
; _|_| _|_|
|
||||
;
|
||||
;
|
||||
;
|
||||
|
||||
; ================
|
||||
; calls start here
|
||||
; ================
|
||||
|
||||
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
|
||||
|
||||
.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
|
||||
|
||||
.done:
|
||||
mov al, 0 ; null terminator
|
||||
stosb
|
||||
|
||||
mov ah, 0x0E
|
||||
mov al, 0x0D
|
||||
int 0x10
|
||||
mov al, 0x0A
|
||||
int 0x10 ; newline
|
||||
|
||||
ret
|
||||
|
||||
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 .done ; 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
|
||||
|
||||
;fill file with zeros
|
||||
times 2025-($-$$) hlt
|
||||
db 'By MrBesen and Thiesyyy';23
|
Loading…
Reference in New Issue