Advertisement
atm959

OSThing

Dec 5th, 2018
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. BITS 16
  2.  
  3. start:
  4.     mov ax, 07C0h       ; Set up 4K stack space after this bootloader
  5.     add ax, 288     ; (4096 + 512) / 16 bytes per paragraph
  6.     mov ss, ax
  7.     mov sp, 4096
  8.  
  9.     mov ax, 07C0h       ; Set data segment to where we're loaded
  10.     mov ds, ax
  11.  
  12.  
  13.     mov ah, 11h
  14.     int 10h
  15.    
  16.     mov si, text_string ; Put string position into SI
  17.     call print_string   ; Call our string-printing routine
  18.  
  19.     jmp $           ; Jump here - infinite loop!
  20.  
  21. text_string:
  22.     db 020h, 0DBh, 0DBh, 0DBh, 020h, 020h, 020h, 0DBh, 0DBh, 0DBh, 020h, 1
  23.     db 0DBh, 020h, 020h, 020h, 0DBh, 020h, 0DBh, 020h, 020h, 020h, 0DBh, 1
  24.     db 0DBh, 020h, 020h, 020h, 0DBh, 020h, 0DBh, 020h, 020h, 020h, 020h, 1
  25.     db 0DBh, 020h, 020h, 020h, 0DBh, 020h, 020h, 0DBh, 0DBh, 0DBh, 020h, 1
  26.     db 0DBh, 020h, 020h, 020h, 0DBh, 020h, 020h, 020h, 020h, 020h, 0DBh, 1
  27.     db 0DBh, 020h, 020h, 020h, 0DBh, 020h, 0DBh, 020h, 020h, 020h, 0DBh, 1
  28.     db 020h, 0DBh, 0DBh, 0DBh, 020h, 020h, 020h, 0DBh, 0DBh, 0DBh, 020h, 1
  29.     db "Press ENTER to start.", 0
  30.  
  31.  
  32. print_string:           ; Routine: output string in SI to screen
  33.     mov ah, 0Eh     ; int 10h 'print char' function
  34.  
  35. .repeat:
  36.     lodsb           ; Get character from string
  37.     cmp al, 0
  38.     je .done        ; If char is zero, end of string
  39.     cmp al, 1
  40.     je .next_line      
  41.     int 10h         ; Otherwise, print it
  42.     jmp .repeat
  43.  
  44. .done:
  45.     ret
  46.  
  47. .next_line:
  48.     push ax
  49.     push bx
  50.     push cx
  51.     push dx
  52.     mov ah, 03h
  53.     int 10h
  54.     mov dl, 00h
  55.     add dh, 01h
  56.     mov ah, 02h
  57.     int 10h
  58.     pop dx
  59.     pop cx
  60.     pop bx
  61.     pop ax
  62.     jmp .repeat
  63.  
  64.     times 510-($-$$) db 0   ; Pad remainder of boot sector with 0s
  65.     dw 0xAA55       ; The standard PC boot signature
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement