Last active
August 28, 2019 13:35
-
-
Save marcoramilli/773feff1424fdb1e9633cc653c16e629 to your computer and use it in GitHub Desktop.
bootloader.img
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.code16 # use 16 bits | |
.global main | |
main: | |
mov $0x0002, %ax | |
int $0x10 #set 80x25 text mode | |
mov $0x0700, %ax | |
mov $0x0f, %bh | |
mov $0x184f, %dx | |
xor %cx, %cx | |
int $0x10 #clear screen (black background) | |
jmp print_message | |
print_living_clock: | |
mov $0x02, %ah | |
mov $0x00, %bh | |
mov $0x012a, %dx | |
int $0x10 #reset cursor position | |
# Read Timer | |
mov $0x02, %ah | |
int $0x1a | |
# Print Hours | |
mov $0x0e, %ah | |
mov %ch, %al | |
int $0x10 | |
# Print '/' | |
mov $0x0e, %ah | |
mov $0x2f, %al | |
int $0x10 | |
# Print Minutes | |
mov $0x0e, %ah | |
mov %cl, %al | |
int $0x10 | |
# Print '/' | |
mov $0x0e, %ah | |
mov $0x2f, %al | |
int $0x10 | |
# Print Seconds | |
mov $0x0e, %ah | |
mov %dh, %al | |
int $0x10 | |
jmp print_living_clock | |
print_message: | |
mov $0x02, %ah | |
mov $0x00, %bh | |
mov $0x0000, %dx | |
int $0x10 # set cursor position | |
mov $msg, %si # loads the address of msg into si | |
mov $0x0001, %cx | |
mov $0xe, %ah # loads 0xe (function number for int 0x10) into ah | |
jmp print_char | |
print_message_2: | |
mov $0x02, %ah | |
mov $0x00, %bh | |
mov $0x0100, %dx | |
int $0x10 # set cursor position | |
mov $msg2, %si # loads the address of msg into si | |
mov $0x0002, %cx | |
mov $0xe, %ah # loads 0xe (function number for int 0x10) into ah | |
jmp print_char | |
print_message_3: | |
mov $0x02, %ah | |
mov $0x00, %bh | |
mov $0x0200, %dx | |
int $0x10 # set cursor position | |
mov $msg3, %si # loads the address of msg into si | |
mov $0x0003, %cx | |
mov $0xe, %ah # loads 0xe (function number for int 0x10) into ah | |
jmp print_char | |
print_char: | |
mov $0x0e, %ah | |
lodsb # loads the byte from the address in si into al and increments si | |
cmp $0, %al # compares content in AL with zero | |
je done # if al == 0, go to "done" | |
mov $0xc0, %bl | |
int $0x10 # prints the character in al to screen | |
jmp print_char # repeat with next byte | |
done: | |
cmp $0x0001, %cx | |
je print_message_2 | |
cmp $0x0002, %cx | |
je print_message_3 | |
cmp $0x0003, %cx | |
je print_living_clock | |
end: | |
hlt #Stops execution | |
msg: .asciz "====================================================" | |
msg2: .asciz " Your First Booting Program " | |
msg3: .asciz "====================================================" | |
.fill 510-(.-init), 1, 0 # add zeroes to make it 510 bytes long | |
.word 0xaa55 # magic bytes that tell BIOS that this is bootable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment