Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .org 0x7C00
- .code16
- start:
- movw %cs, %ax
- movw %ax, %ds
- movw %ax, %ss
- movw start, %sp
- call clean_screen
- load_kernel:
- movw $0x1100, %ax
- movw %ax, %es
- movw $0x00, %bx
- movb $0x02, %ah
- movb $1, %dl
- movb $0, %dh
- movb $0, %ch
- movb $2, %cl #Pointer to raw data
- movb $15,%al #Size of raw data
- int $0x13
- movw $0x1300, %ax
- movw %ax, %es
- movw $0x0, %bx
- movb $0x02, %ah
- movb $1, %dl
- movb $0, %dh
- movb $0, %ch
- movb $17, %cl #Pointer to raw data
- movb $2,%al #Size of raw data
- int $0x13
- movw $0x1360, %ax
- movw %ax, %es
- movw $0x00, %bx
- movb $0x02, %ah
- movb $1, %dl
- movb $0, %dh
- movb $1, %ch
- movb $1, %cl #Pointer to raw data
- movb $18,%al #Size of raw data
- int $0x13
- movw $0x1660, %ax
- movw %ax, %es
- movw $0x00, %bx
- movb $0x02, %ah
- movb $1, %dl
- movb $1, %dh
- movb $0, %ch
- movb $1, %cl #Pointer to raw data
- movb $18,%al #Size of raw data
- int $0x13
- movw $0x1960, %ax
- movw %ax, %es
- movw $0x00, %bx
- movb $0x02, %ah
- movb $1, %dl
- movb $0, %dh
- movb $1, %ch
- movb $1, %cl #Pointer to raw data
- movb $17,%al #Size of raw data
- int $0x13
- movw $hello_string, %bx
- call puts
- hello_world:
- movb $0, %ah
- int $0x16
- cmpb $32, %al
- je clean_screen_hello
- jne hello_world
- print_string:
- movw $alphabet_copy, %bx
- movw $alphabet_string, %cx
- call puts
- jmp input_letters
- output_string:
- movw $alphabet_string, %ax
- movw %ax, %es
- movw $0, %bx
- movb $3, %ah
- movb $1, %dl
- movb $0x00, %dh
- movb $0, %ch
- movb $0x01, %cl #Pointer to raw data
- movb $1, %al #size of raw data
- int $0x13
- before_ProtectedMode:
- cli
- lgdt gdt_info
- inb $0x92, %al
- orb $2, %al
- outb %al, $0x92
- movl %cr0, %eax
- orb $1, %al
- movl %eax, %cr0
- ljmp $0x8, $protected_mode
- input_letters:
- movb $0, %ah
- int $0x16
- cmpb $0x0D, %al
- je output_string #If a symbol was "Enter"
- inf_loop:
- cmpb 0(%bx), %al
- je delete_letter
- addw $1, %bx
- addw $1, %cx
- jmp inf_loop
- delete_letter:
- movw %cx, %bx
- movb 0(%bx), %ah
- cmpb $0x5F, %ah
- je swap
- movb $0x5F, %ah
- movb %ah, 0(%bx)
- call clean_screen
- movw $alphabet_string, %bx
- movw $alphabet_string, %cx
- call puts
- jmp input_letters
- swap:
- movb %al, 0(%bx)
- call clean_screen
- movw $alphabet_string, %bx
- movw $alphabet_string, %cx
- call puts
- jmp input_letters
- alphabet_string:
- .asciz "abcdefghijklmnopqrstuvwxyz"
- alphabet_copy:
- .asciz "abcdefghijklmnopqrstuvwxyz"
- hello_string:
- .asciz "Hello, it's Dict_OS' bootloader, if u want to enter letter, press space!"
- puts:
- movb 0(%bx), %al
- test %al, %al
- jz end_puts
- movb $0x0e, %ah
- int $0x10
- addw $1, %bx
- jmp puts
- end_puts:
- movw $alphabet_copy, %bx
- ret
- clean_screen:
- movb $0, %ah
- movb $2, %al
- int $0x10
- ret
- clean_screen_hello:
- xorw %bx,%bx
- movb $0, %ah
- movb $2, %al
- int $0x10
- jmp print_string
- gdt:
- .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
- .byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x9A, 0xCF, 0x00
- .byte 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0xCF, 0x00
- gdt_info:
- .word gdt_info - gdt
- .word gdt, 0
- .code32
- protected_mode:
- # Здесь идут первые инструкции в защищенном режиме
- movw $0x10, %ax
- movw %ax, %es
- movw %ax, %ds
- movw %ax, %ss
- call 0x11000
- .zero (512 - (. - start) - 2)
- .byte 0x55, 0xAA
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement