Advertisement
tristanseifert

Untitled

Oct 12th, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     BITS    16
  2.     org     $0000
  3.  
  4. stage2_start:
  5.     mov     ax, 0
  6.     mov     ss, ax                                              ; Set stack segment and pointer
  7.     mov     sp, $0000
  8.  
  9.     mov     ax, $1000                                           ; Set segments to where we're loaded
  10.     mov     ds, ax
  11.  
  12.     mov     si, str_stage2loaded                                ; Put string position into SI
  13.     call    print_string                                        ; Call string printing routine
  14.  
  15.     jmp     $                                                   ; Jump here - infinite loop!
  16.  
  17. ;========================================================================================
  18. ; Outputs the string in SI to the VGA adapter in text mode using INT10h.
  19. ;========================================================================================
  20. print_string:
  21.     mov     ah, $0E                                             ; int 10h 'print char' function
  22.  
  23. .repeat:
  24.     lodsb                                                       ; Get character from string
  25.     cmp     al, 0
  26.     je      .done                                               ; If char is zero, end of string
  27.    
  28.     cmp     al, $0A                                             ; Process newline
  29.     je      .newline
  30.  
  31.     int     $10                                                 ; Otherwise, print it (jump into BIOS)
  32.     jmp     .repeat
  33.  
  34. .done:
  35.     ret
  36.  
  37. .newline:
  38.     mov     ah, $0E
  39.     mov     al, $0D
  40.     int     $10
  41.     mov     al, $0A
  42.     int     $10
  43.     mov     ah, $0E                                             ; int 10h 'print char' function
  44.     jmp     .repeat
  45. ;========================================================================================
  46. ; DATA SECTION
  47. ;========================================================================================
  48. str_stage2loaded:
  49.     db  'Stage 2 loaded!', 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement