aboutsummaryrefslogtreecommitdiffstats
path: root/print.asm
diff options
context:
space:
mode:
authorxeno <xeno@eisberg.nacht>2017-02-23 23:49:18 +0100
committerxeno <xeno@eisberg.nacht>2017-02-23 23:49:18 +0100
commitce7317daf7c9740bc8595f14f7248fa1b050afcf (patch)
treef2d14fd243b5f8235e9e467ad151fd70ecb6dd1e /print.asm
initial commit with some old assembly stuff
Diffstat (limited to 'print.asm')
-rw-r--r--print.asm44
1 files changed, 44 insertions, 0 deletions
diff --git a/print.asm b/print.asm
new file mode 100644
index 0000000..97acd8b
--- /dev/null
+++ b/print.asm
@@ -0,0 +1,44 @@
+org 7C00h
+
+jmp _start
+
+hello: db 'Hello from the first stage!', 0x0A, 0x0D, 0x0
+
+_start:
+
+; print hello message
+
+mov ah, 0x0E
+xor esi, esi
+xor edi, edi
+mov si, hello
+cld
+
+.loop:
+lodsb
+cmp al, 0x00
+je .out
+int 0x10
+jmp .loop
+.out:
+
+; load sectors from disk and jump there
+
+mov ah, 0x02 ; load sectory from disk
+mov al, 0x01 ; load one sector
+xor ch, ch ; cylinder number
+mov cl, 0x02 ; start from sector 2
+xor dh, dh ; head number
+xor dl, dl ; drive number
+
+mov bx, 0x0500 ; start address (see jmp)
+ ; 0x00000500 to 0x00007BFF, from Overview at http://wiki.osdev.org/Memory_Map_%28x86%29
+int 0x13
+
+jmp 0x0500
+
+jmp $
+
+; stolen from: https://en.wikibooks.org/wiki/X86_Assembly/Bootloaders
+times 0200h - 2 - ($ - $$) db 0 ;Zerofill up to 510 bytes
+dw 0AA55h ;Boot Sector signature