Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # bootblock.s
- # .equ symbol, expression.
- # This directive sets the value of symbol to expression
- .equ BOOT_SEGMENT, 0x7c00
- .equ DISPLAY_SEGMENT, 0xb800
- .text # Code segment
- .globl _start # The entry point must be global
- .code16 # Real mode
- #
- # The first instruction to execute in a program is called the entry
- # point. The linker expects to find the entry point in the "symbol" _start
- # (with underscore).
- #
- _start:
- jmp over
- #
- # Do not add any instructions before or in os_size.
- #
- os_size:
- # area reserved for createimage to write the OS size
- .word 0
- .word 0
- over:
- #xchg %bx, %bx
- #print_string is now working, kernel isn't
- # set up segments
- mov $0x0, %ax
- mov %ax, %ds
- mov %ax, %es
- mov %ax, %ss # setup stack
- mov $BOOT_SEGMENT, %sp # stack grows downwards from 0x7C00
- #xchg %bx, %bx
- mov $hellostring, %si
- add $BOOT_SEGMENT, %si
- call print_string
- #INT 13h AH=00h: Reset Disk Drive
- #xchg %bx, %bx
- movb $0x00, %ah
- int $0x13
- #INT 13h AH=08h: Read Drive Parameters
- #xchg %bx, %bx
- xor %ax, %ax
- mov %ax, %es
- mov %ax, %di
- mov $0x08, %ah
- mov $0x80, %dl
- int $0x13
- #INT 13h AH=02h: Read Sectors From Drive
- #xchg %bx, %bx
- xor %ax, %ax
- mov %ax, %es
- mov $0x0550, %bx
- movb $0x02, %ah
- movb $0x01, %al
- movb $0x00, %ch
- movb $0x01, %cl
- movb $0x00, %dh
- movb $0x80, %dl
- #xchg %bx, %bx
- int $0x13
- #INT 13h AH=02h: Read Sectors From Drive
- #xchg %bx, %bx
- xor %ax, %ax
- mov %ax, %es
- mov $0x8000, %bx
- movb $0x02, %ah
- movb $0x01, %al
- movb $0x00, %ch
- movb $0x02, %cl
- movb $0x00, %dh
- movb $0x80, %dl
- int $0x13
- #xchg %bx, %bx
- mov $0x00, %ax
- mov %ax, %ds
- #invoke kernel at 0x00008000
- ljmp $0x0, $0x8000
- print_string:
- mov $0x0e, %ah
- .repeat:
- lodsb
- cmp $0x00, %al
- je .done
- int $0x10
- jmp .repeat
- .done:
- ret
- forever:
- jmp forever # Loop forever
- hellostring:
- .asciz "Hello\r\n"
- . = _start + 510 #mov to 510th byte from 0 pos
- .byte 0x55 #append boot signature
- .byte 0xaa #append boot signature
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement