title: Bootloader with graphics (NASM)
body: <p>I have written simple bootloader based on: <a href="http://www.viralpatel.net/taj/tutorial/hello_world_bootloader.php" rel="noreferrer">http://www.viralpatel.net/taj/tutorial/hello_world_bootloader.php</a></p>
  
  <pre><code>[BITS 16]   ;16bit
  [ORG 0x7C00]    ;offset
  
  MOV AH, 0x00 ; change video mode
  MOV AL, 0x13 ; 0x13
  INT 0x10 ; interrupt
  CALL DrawTenLines   ;lets draw
  JMP $       ;hang it
  
  DrawOneLine:
  MOV CX, 0x00 ;x = 0
  
  nextpixel:
  MOV AH, 0x09 ;func number - WritePixelOnScreen [wiki]
  MOV AL, 0x05 ;color - Magenta
  MOV BH, 0x00 ;Page no
  INT 0x10 ;Video interrupt - BIOS
  CMP CX, 10 ;if (x == 10) {
  JE exitfunc ;exit function } else {
  JNE nextpixel ;next pixel }
  ADD CX, 0x01 ;add one :D
  exitfunc: ;exit :D
  RET
  
  DrawTenLines: ;draw some lines
  MOV DX, 0x00 ;y = 0
  CALL DrawOneLine
  MOV DX, 0x01 ;y = 1
  CALL DrawOneLine
  MOV DX, 0x02 ;y = 2
  CALL DrawOneLine
  MOV DX, 0x03 ;y = 3
  CALL DrawOneLine
  MOV DX, 0x04 ;y = 4
  CALL DrawOneLine
  MOV DX, 0x05 ;y = 5
  CALL DrawOneLine
  RET
  
  ;Data
  
  TIMES 510 - ($ - $$) db 0   ;Fillers
  DW 0xAA55           ;boot signature
  </code></pre>
  
  <p>But this doesn't work as expected - doesn't draw, only black screen and hangs (as expected).</p>
  
  <p>Compiled with NASM, -f bin. Example from this site works. Tested in Virtualbox.</p>
  
  <p>EDIT: Forgotten to change video mode - but still doesn't work.</p>
  
  <p>EDIT 2: This code:
      [BITS 16]   ;16bit
      [ORG 0x7C00]    ;offset</p>
  
  <pre><code>MOV AH, 0x00
  MOV AL, 0x13
  INT 0x10
  MOV AH, 0x09 ;WritePixelOnScreen [wiki]
  MOV AL, 0x0F ;color - White
  MOV BH, 0x00 ;page no. 
  MOV CX, 1 ;x
  MOV DX, 1 ;y
  INT 0x10 ;interrupt
  MOV CX, 2 ;x
  MOV DX, 1 ;y
  INT 0x10 ;interrupt
  MOV CX, 3 ;x
  MOV DX, 1 ;y
  INT 0x10 ;interrupt
  JMP $       ;hang
  
  ;Data
  
  TIMES 510 - ($ - $$) db 0   ;filler
  DW 0xAA55           ;boot signature
  </code></pre>
  
  <p>Makes:
  <a href="http://i.imgur.com/UGS3m.png" rel="noreferrer">http://i.imgur.com/UGS3m.png</a></p>