cs401 assignment 3 solution fall 2019 2020

cs401 assignment 3 solution fall 2019 2020

 

Question:

Suppose we want to draw a square on our computer screen as shown below.

 

name “vga”

 

; this program draws a square in vga mode.

 

org  100h

 

jmp code

 

; dimensions of the square:

; width:  50 pixels

; height: 50 pixels

 

w equ 50

h equ 50

 



; set video mode 13h – 320×200

 

code:   mov ah, 0

mov al, 13h

int 10h

 

 

; draw upper line:

 

mov cx, 100+w  ; column

mov dx, 20     ; row

mov al, 0010     ; green

u1: mov ah, 0ch    ; put pixel

int 10h

 

dec cx

cmp cx, 100

jae u1

 

; draw bottom line:

 

mov cx, 100+w  ; column

mov dx, 20+h   ; row

mov al, 0001     ; blue

u2: mov ah, 0ch    ; put pixel

int 10h

 

dec cx

cmp cx, 100

ja u2

 

; draw left line:



mov cx, 100    ; column

mov dx, 20+h   ; row

mov al, 35      ; pink

u3: mov ah, 0ch    ; put pixel

int 10h

 

dec dx

cmp dx, 20

ja u3

 

 

; draw right line:

 

mov cx, 100+w  ; column

mov dx, 20+h   ; row

mov al, 20    ; gray

u4: mov ah, 0ch    ; put pixel

int 10h

 

dec dx

cmp dx, 20

ja u4

 

 

; pause the screen for dos compatibility:

 

;wait for keypress

mov ah,00

int 16h

 

; return to text mode:

mov ah,00

mov al,03 ;text mode 3

int 10h

 

 

 

ret

 

You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: