CS401 Assignment 3 Solution and Discussion


  • Cyberian's Gold

    Computer Architecture and Assembly Language Programming (CS401)
    Assignment # 03
    Total marks = 20

    Due Date:
    January 20, 2020
    Please carefully read the following instructions before attempting assignment.
    RULES FOR MARKING
    It should be clear that your assignment would not get any credit if:
    • The assignment is submitted after the due date.
    • The submitted assignment does not open or file is corrupt.
    • Strict action will be taken if submitted solution is copied from any other student or from the internet.

    You should concern the recommended books to clarify your concepts as handouts are not sufficient.
    You are supposed to submit your assignment in .doc or docx format.
    Any other formats like scan images, PDF, zip, rar, ppt and bmp etc. will not be accepted.
    Topic Covered:
    • BIOS VIDEO SERVICES AND GRAPHICS MODE SERVICES
    NOTE
    No assignment will be accepted after the due date via email in any case (whether it is the case of load shedding or internet malfunctioning etc.). Hence refrain from uploading assignment in the last hour of deadline. It is recommended to upload solution file at least two days before its closing date.
    If you people find any mistake or confusion in assignment (Question statement), please consult with your instructor before the deadline. After the deadline no queries will be entertained in this regard.
    For any query, feel free to email at [email protected]

    Question Statement
    Suppose we want to draw a square on our computer screen as shown below.
    9dfcc405-cdf8-404b-a47f-e45d9e9976c0-image.png
    You are required to write an assembly language program to draw a square as given above using video interrupts.
    Note:
    a. Upper horizontal line must be Green
    b. Lower horizontal line must be blue
    c. Left vertical line must be PINK
    d. Right vertical line must be Gray.

    “The End”


  • Cyberian's Gold

    [ORG 0X0100]
    start: mov ax, 0x000D     					
    	int 0x10
    	mov ax, 0x0C02					
    	xor bx, bx
    	mov cx, 100
    	mov dx, 60
    l1: int 0x10							
    	inc cx
            cmp cx, 200
            jne l1
    	mov cx, 100
    	mov dx, 60
    l2: int 0x10							
    	mov ax, 0x0C05
            inc dx
            cmp dx, 120
            jne l2
    	mov cx, 200
    	mov dx, 60
    l3: int 0x10 							
    	mov ax, 0x0C08
            inc dx
            cmp dx, 120
            jne l3
    	mov cx, 100
    	mov dx, 120
    l4: int 10h							
    	mov ax, 0x0C09
            inc cx
            cmp cx, 200
            jne l4
    	mov ah, 0 
    	int 0x16
    	mov ax, 0x0003 
    	int 0x10
            mov ax, 0x4C00
    int 0x21
    
    

  • Cyberian's Gold

    [ORG 0X0100]
    start: mov ax, 0x000D     					
    	int 0x10
    	mov ax, 0x0C02					
    	xor bx, bx
    	mov cx, 100
    	mov dx, 60
    l1: int 0x10							
    	inc cx
            cmp cx, 200
            jne l1
    	mov cx, 100
    	mov dx, 60
    l2: int 0x10							
    	mov ax, 0x0C05
            inc dx
            cmp dx, 120
            jne l2
    	mov cx, 200
    	mov dx, 60
    l3: int 0x10 							
    	mov ax, 0x0C08
            inc dx
            cmp dx, 120
            jne l3
    	mov cx, 100
    	mov dx, 120
    l4: int 10h							
    	mov ax, 0x0C09
            inc cx
            cmp cx, 200
            jne l4
    	mov ah, 0 
    	int 0x16
    	mov ax, 0x0003 
    	int 0x10
            mov ax, 0x4C00
    int 0x21
    
    

  • Cyberian's Gold

    Idea Solution code:

                                                               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 - 320x200
    
    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
    
    


Quiz 100% Result
| |