Advertisement
metalx1000

Very Basic Boot Loader with Keyboard input

Oct 15th, 2013
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     BITS 16
  2.  
  3.     start:
  4.     ;Clears screen
  5.     ;----------------------------------------------
  6.     mov ah, 0x0F            ;get current video mode
  7.     int 0x10                ;get video mode
  8.     mov ah, 0x00            ;set video mode
  9.     int 0x10                ;reset screen
  10.     mov ah, 0x02            ;set cursor pos
  11.     int 0x10                ;set pos
  12.     ;----------------------------------------------
  13.  
  14.     mov dl,1
  15.     .repeat:
  16.         lodsb ; Get character from string
  17.         cmp al, 0
  18.         je .cursor_pointer; If char is zero, end of string
  19.         int 10h ; Otherwise, print it
  20.         jmp .repeat
  21.     .cursor_pointer:
  22.         mov ah,2h ;set the value to "ah" to move the cursor pointer
  23.         mov bh,0 ;select page
  24.         mov dh,22 ;set row position of the cursor
  25.         add dl,1 ;set column position of the cursor
  26.         int 10h ;tell bios "hey dude now we are done,take action!!!"
  27.         jmp .character_read
  28.     .character_read:
  29.         mov ah,4h
  30.         mov ah,00h ;remeber set the value to "ah" now you are going to read a keyboard input
  31.         int 16h ;this interrupt is given to control keystrokes of keyboard
  32.         jmp .print_input ;now lets print what we took as input
  33.     .print_input:
  34.         mov ah,9h ;set the value to "ah" to print one character to std out
  35.         mov bh,0 ;set page number
  36.         mov bl,5h ;set the color attribute of the font to be print
  37.         mov cx,1 ;set the value how many time the character in "al" should be print
  38.         int 10h ;tell bios "hey dude now we are done,take action!!!"
  39.         jmp .cursor_pointer
  40.     times 510-($-$$) db 0 ; fill up the rest part of the boot secotr with 0 s
  41.     dw 0xAA55 ; The standard PC boot signature
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement