C S C O R N E R

Draw a pattern using BIOS Video Services in Assembly

In this example I have used,
  • Pixel color white
  • X and Y coordinates position are equal to 20 i.e X-axis = 20, Y-axis = 20
  • Using 16bit assembly programming and NASM assembler
Code:

org 100h
 
mov ah, 0h      ; set display mode function.
mov al, 4h      ; 320x200 4 color graphics .
int 10h         ; set it!
 
mov ah, 0Ch     ; put pixel
mov al, 7       ;color
mov bh, 0       ;page
 
mov cx, 0h      ;starting from coll 0
mov dx, 0h      ;starting from row 0
 
Count1:
  
inc cx
inc dx          ;increment until these are 20
int 0x10
  
cmp cx, 14h     ;check if its 20 / loop to draw 20 pixels
JNE Count1
 
; repeating to draw 2nd line
 
mov ah, 0Ch     ;put pixel
mov al, 7       ;color
mov bh, 0       ;page
 
mov cx, 14h     ;starting from coll 20
mov dx, 0h      ;starting from row 0
 
Count2:
  
dec cx 
inc dx
int 0x10
 
cmp cx, 0
JNE Count2
 
mov ah, 0        ;just to stop the screen ( works like getch())
int 0x16 
 
mov ax, 0x4c00   ;terminating
int 0x21

Output:

No comments:

Powered by Blogger.