title: Cannot draw pixels on Y-axis with INT 10h / AH = 0Ch
body: <p>I have the following code fragment which should draw a diagonal starting from (30, 100), however, it simply paints a horizontal line on top of the screen, like this:</p>
  
  <p><a href="https://i.stack.imgur.com/3Zu5y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Zu5y.png" alt="enter image description here"></a></p>
  
  <p>To test the code, I run <code>make run</code>.</p>
  
  <p>This is <code>loader.asm</code>:</p>
  
  <pre><code>    BITS 16
  
  ; ----------------------------------------------------------------------
  
  _start:
      mov ax, 07C0h
      add ax, 288
      mov ss, ax              ; ss = stack space
      mov sp, 4096            ; sp = stack pointer
  
      mov ax, 07C0h
      mov ds, ax              ; ds = data segment
  
      call print_pixel
  
      jmp $                   ; infinite loop
  
  ; ----------------------------------------------------------------------
  
  print_pixel:
  
      ; changing video mode to graphical
  
      mov ah, 00h             ; set video mode
  
      mov al, 13h             ; 13h - graphical mode.
                              ; 40x25. 256 colors.;320x200 pixels. 1 page.
  
      int 10h                 ; call
  
      ; drawing random pixels
  
      mov ah, 0Ch             ; change color for a single pixel
  
      mov al, 0000b           ; color
      mov bh, 0               ; page number
      mov cx, 30              ; x
      mov dx, 100             ; y
  
      int 10h                 ; paint 1st pixel
  
  .repeat:
  
      inc al                  ; change color
      inc cx                  ; go one pixel right
      inc dx                  ; go one pixel down
  
      int 10h                 ; paint
  
      cmp al, 1111b
      je .done                ; last color was painted
  
      jmp .repeat
  
  .done:
      ret
  
  times 510 - ($ - $$) db 0   ; padding with 0 at the end
  dw 0xAA55                   ; PC boot signature
  </code></pre>
  
  <p>This is <code>Makefile</code>:</p>
  
  <pre><code>.PHONY: build run
  
  build: image.flp
  
  run: build
      qemu-system-i386 -fda image.flp
  
  image.bin: loader.asm
      nasm -f bin -o image.bin loader.asm
  
  image.flp: image.bin
      dd status=noxfer conv=notrunc if=image.bin of=image.flp
  </code></pre>