Advertisement
Guest User

Untitled

a guest
Feb 8th, 2012
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. org 0x7c00 ; Loaded at address 0x7c00 by BIOS.
  2.  
  3. CR equ 0x0d
  4. LF equ 0x0a
  5.  
  6. ; http://en.wikipedia.org/wiki/BIOS_color_attributes
  7. black equ 0x00
  8. blue equ 0x01
  9. green equ 0x02
  10. cyan equ 0x03
  11. red equ 0x04
  12. magenta equ 0x05
  13. brown equ 0x06
  14. light_grey equ 0x07
  15. dark_grey equ 0x08
  16. light_blue equ 0x09
  17. light_green equ 0x0a
  18. light_cyan equ 0x0b
  19. light_red equ 0x0c
  20. light_magenta equ 0x0d
  21. yellow equ 0x0e
  22. white equ 0x0f
  23.  
  24. start:
  25.     jmp main
  26.  
  27. print:
  28.     lodsb
  29.     or al, al
  30.     jz print_end
  31.     mov ah, 0x0e
  32.     mov bl, white
  33.     int 0x10
  34.     jmp print
  35.  
  36. print_end:
  37.     ret
  38.  
  39. switch_to_mode_0x12: ; VGA 640x480 16
  40.     ; http://en.wikipedia.org/wiki/INT_10H
  41.     ;   Set video mode
  42.     ;   AH=00h
  43.     ;   AL = video mode
  44.     xor ah, ah
  45.     mov al, 0x12
  46.     int 0x10
  47.     ret
  48.  
  49. main:
  50.     xor ax, ax ; Set DS register to zero
  51.     mov ds, ax ; because we set org to 0x7c00
  52.     cld
  53.    
  54.     ; http://en.wikipedia.org/wiki/INT_10H
  55.     ;   Teletype output
  56.     ;   AH=0Eh
  57.     ;   AL = Character
  58.     ;   BH = Page Number
  59.     ;   BL = Color (only in graphic mode)
  60.     ;
  61.     ; Need to switch to a graphic mode.
  62.     ; http://www.wagemakers.be/english/doc/vga lists mode 0x12 as a graphic mode.
  63.     call switch_to_mode_0x12
  64.    
  65.     ; http://en.wikipedia.org/wiki/INT_10H
  66.     ;   Set background/border color
  67.     ;   AH=0Bh,
  68.     ;   BH = 00h
  69.     ;   BL = Background/Border color (border only in text modes)
  70.     mov ah, 0x0b
  71.     xor bh, bh
  72.     mov bl, white
  73.     int 0x10
  74.    
  75.     mov si, msg
  76.     call print
  77.    
  78.     cli
  79.     hlt
  80.  
  81. msg db 'Hello', CR, LF, '-----', 0
  82.  
  83. times 512-($-$$) db 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement