Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Just copied over and cleaned up.

  • Loading branch information...
commit b54d1624489afa4dde35e4aa1a1932b60f1c201c 1 parent 87f9f22
@solidsnack authored
Showing with 63 additions and 0 deletions.
  1. +63 −0 ayb.nasm
View
63 ayb.nasm
@@ -0,0 +1,63 @@
+; From http://en.wikibooks.org/wiki/X86_Assembly/Bootloaders
+
+ org 0x7C00 ; Relocate code to where the BIOS expects it.
+
+ jmp short Start ; Jump over the data (the 'short' keyword makes
+ ; the jmp instruction smaller).
+
+Msg: db "Hello World! "
+EndMsg:
+
+Start: mov bx, 0x000F ; Page 0, colour attribute 15 (white) for the
+ ; int 10 calls below.
+ mov cx, 1 ; We will want to write 1 character.
+ xor dx, dx ; Start at top left corner.
+ mov ds, dx ; Ensure ds = 0 (to let us load the message).
+ cld ; Ensure direction flag is cleared (for LODSB).
+
+Print: mov si, Msg ; Loads the address of the first byte of the
+ ; message, 0x7C02 in this case.
+
+ ; PC BIOS Interrupt 10 Subfunction 2 - Set
+ ; cursor position.
+ ; AH = 2
+Char: mov ah, 2 ; BH = page, DH = row, DL = column.
+ int 0x10
+ lodsb ; Load a byte of the message into AL.
+ ; Remember that DS is 0 and SI holds the
+ ; offset of one of the bytes of the message.
+
+ ; PC BIOS Interrupt 10 Subfunction 9 - Write
+ ; character and colour.
+ ; AH = 9
+ mov ah, 9 ; BH = page
+ ; AL = character
+ ; BL = attribute
+ ; CX = character count
+ int 0x10
+
+ inc dl ; Advance cursor.
+
+ cmp dl, 80 ; Wrap around edge of screen if necessary.
+ jne Skip
+ xor dl, dl
+ inc dh
+
+ cmp dh, 25 ; Wrap around bottom of screen if necessary.
+ jne Skip
+ xor dh, dh
+
+Skip: cmp si, EndMsg ; If we're not at end of message,
+ jne Char ; continue loading characters,
+ jmp Print ; otherwise restart from the beginning of the
+ ; message.
+
+
+times 0200h - 2 - ($ - $$) db 0 ; Zerofill up to 510 bytes.
+
+ dw 0AA55h ; Boot Sector signature.
+
+;OPTIONAL:
+;To zerofill up to the size of a standard 1.44MB, 3.5" floppy disk.
+;times 1474560 - ($ - $$) db 0
+
Please sign in to comment.
Something went wrong with that request. Please try again.