add build files
This commit is contained in:
parent
4ef6b1dc58
commit
6c37358fb2
3
.sh
Normal file
3
.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
sudo apt install make nasm qemu
|
||||||
|
# snap install micro --classic
|
||||||
|
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019 chibicitiberiu
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
11
Makefile
Normal file
11
Makefile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
ASM=nasm
|
||||||
|
|
||||||
|
SRC_DIR=src
|
||||||
|
BUILD_DIR=build
|
||||||
|
|
||||||
|
$(BUILD_DIR)/main_floppy.img: $(BUILD_DIR)/main.bin
|
||||||
|
cp $(BUILD_DIR)/main.bin $(BUILD_DIR)/main_floppy.img
|
||||||
|
truncate -s 1440k $(BUILD_DIR)/main_floppy.img
|
||||||
|
|
||||||
|
$(BUILD_DIR)/main.bin: $(SRC_DIR)/main.asm
|
||||||
|
$(ASM) $(SRC_DIR)/main.asm -f bin -o $(BUILD_DIR)/main.bin
|
BIN
build/main.bin
Normal file
BIN
build/main.bin
Normal file
Binary file not shown.
BIN
build/main_floppy.img
Normal file
BIN
build/main_floppy.img
Normal file
Binary file not shown.
2
install_packages.sh
Normal file
2
install_packages.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
sudo apt install make nasm qemu
|
||||||
|
|
67
src/main.asm
Normal file
67
src/main.asm
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
; https://github.com/nanobyte-dev/nanobyte_os/blob/Part1/src/main.asm
|
||||||
|
org 0x7C00
|
||||||
|
bits 16
|
||||||
|
|
||||||
|
|
||||||
|
%define ENDL 0x0D, 0x0A
|
||||||
|
|
||||||
|
|
||||||
|
start:
|
||||||
|
jmp main
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
; Prints a string to the screen
|
||||||
|
; Params:
|
||||||
|
; - ds:si points to string
|
||||||
|
;
|
||||||
|
puts:
|
||||||
|
; save registers we will modify
|
||||||
|
push si
|
||||||
|
push ax
|
||||||
|
push bx
|
||||||
|
|
||||||
|
.loop:
|
||||||
|
lodsb ; loads next character in al
|
||||||
|
or al, al ; verify if next character is null?
|
||||||
|
jz .done
|
||||||
|
|
||||||
|
mov ah, 0x0E ; call bios interrupt
|
||||||
|
mov bh, 0 ; set page number to 0
|
||||||
|
int 0x10
|
||||||
|
|
||||||
|
jmp .loop
|
||||||
|
|
||||||
|
.done:
|
||||||
|
pop bx
|
||||||
|
pop ax
|
||||||
|
pop si
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
main:
|
||||||
|
; setup data segments
|
||||||
|
mov ax, 0 ; can't set ds/es directly
|
||||||
|
mov ds, ax
|
||||||
|
mov es, ax
|
||||||
|
|
||||||
|
; setup stack
|
||||||
|
mov ss, ax
|
||||||
|
mov sp, 0x7C00 ; stack grows downwards from where we are loaded in memory
|
||||||
|
|
||||||
|
; print hello world message
|
||||||
|
mov si, msg_hello
|
||||||
|
call puts
|
||||||
|
|
||||||
|
hlt
|
||||||
|
|
||||||
|
.halt
|
||||||
|
jmp .halt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
msg_hello: db 'Hello world!', ENDL, 0
|
||||||
|
|
||||||
|
|
||||||
|
times 510-($-$$) db 0
|
||||||
|
dw 0AA55h
|
1
start-qemu.sh
Executable file
1
start-qemu.sh
Executable file
@ -0,0 +1 @@
|
|||||||
|
qemu-system-i386 -fda build/main_floppy.img
|
Loading…
x
Reference in New Issue
Block a user