Navigation

    Cyberian
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Pro Blog
    • Users
    • Groups
    • Unsolved
    • Solved

    SOLVED CS401 Assignment 2 Solution and Discussion

    CS401 - Computer Architecture and Assembly Language Programming
    cs401 assignment 2 solution discussion fall 2019
    1
    3
    1423
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • zareen
      zareen Cyberian's Gold last edited by

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

      Deadline Date
      Nov 26, 2019

      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:
      • Addressing Modes
      • Branching
      • Subroutines•
      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]

      Q1. Write a subroutine that will find the first even number from an array of your VU ID and calculate its factorial. (10 Marks)

      Note: Skip 0’s in your VU ID as shown below,
      VU ID: BC190206435
      After skipping 0’s, array would be:
      Array: 1, 9, 2, 6, 4, 3, 5
      The first even number is 2 in the array so its factorial will be calculated and saved in AX register.

      Q2. Write a code in assembly language (using appropriate jumps) equivalent to this given code in C. (10 Marks)

      #include <stdio.h>
      int main()
      {
          int n1=1, n2=2;
          int largest;
          if( n1>n2)
              largest=n1;
      else
              largest = n2;
          return 0;
      }
      

      “The End”

      Discussion is right way to get Solution of the every assignment, Quiz and GDB.
      We are always here to discuss and Guideline, Please Don't visit Cyberian only for Solution.
      Cyberian Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
      NOTE: Don't copy or replicating idea solutions.
      Quiz Copy Solution
      Mid and Final Past Papers
      Live Chat

      1 Reply Last reply Reply Quote 0
      • zareen
        zareen Cyberian's Gold last edited by

        Q1. Write a subroutine that will find the first even number from an array of your VU ID and calculate its factorial. (10 Marks)

        Note: Skip 0’s in your VU ID as shown below,
        VU ID: BC190206435
        After skipping 0’s, array would be:
        Array: 1, 9, 2, 6, 4, 3, 5
        The first even number is 2 in the array so its factorial will be calculated and saved in AX register.
        Solution:

        [org 0x100]
        	jmp start
        data:  dw 1, 9,2,6,4,3,5
             
        
        ;initiliazation
        
        
        checkEven:  
                mov dl,0002h          
                mov ax,[data+bx]
                mov cx,[data+bx]
                xor ah,ah
                xor ch,ch
                div dl
                cmp ah,00h    ;checking remainder
                je fact
                add bx,2
                jmp checkEven
        fact:   
                mov ax,0001
                mov dx,0000
        mult:	
                mul cx
                loop mult
        	
                ret
        
        start:  mov si,00h
                   mov bx,si
                   call checkEven
        	                  
                
        mov ax,0x4c00
        int 0x21
        

        Q2. Write a code in assembly language (using appropriate jumps) equivalent to this given code in C. (10 Marks)
        #include <stdio.h>
        int main()
        {
        int n1=1, n2=2;
        int largest;
        if( n1>n2)
        largest=n1;
        else
        largest = n2;
        return 0;
        }

        Solution:

        Assembly code:

        [org 0x100]
        jmp start
        n1 db 1
        n2 db 2
        largest db 0
        
        start:
        	mov ax, [n1]
        	xor ah,ah
        	mov bx, [n2]
        	cmp ax,bx
        	ja large
        	mov [largest],bx 
        
        large:  mov [largest],ax
        
        
        mov ax, 0x4c00
        int 21h
        

        Discussion is right way to get Solution of the every assignment, Quiz and GDB.
        We are always here to discuss and Guideline, Please Don't visit Cyberian only for Solution.
        Cyberian Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
        NOTE: Don't copy or replicating idea solutions.
        Quiz Copy Solution
        Mid and Final Past Papers
        Live Chat

        1 Reply Last reply Reply Quote 0
        • zareen
          zareen Cyberian's Gold last edited by

          Q1. Write a subroutine that will find the first even number from an array of your VU ID and calculate its factorial. (10 Marks)

          Note: Skip 0’s in your VU ID as shown below,
          VU ID: BC190206435
          After skipping 0’s, array would be:
          Array: 1, 9, 2, 6, 4, 3, 5
          The first even number is 2 in the array so its factorial will be calculated and saved in AX register.
          Solution:

          [org 0x100]
          	jmp start
          data:  dw 1, 9,2,6,4,3,5
               
          
          ;initiliazation
          
          
          checkEven:  
                  mov dl,0002h          
                  mov ax,[data+bx]
                  mov cx,[data+bx]
                  xor ah,ah
                  xor ch,ch
                  div dl
                  cmp ah,00h    ;checking remainder
                  je fact
                  add bx,2
                  jmp checkEven
          fact:   
                  mov ax,0001
                  mov dx,0000
          mult:	
                  mul cx
                  loop mult
          	
                  ret
          
          start:  mov si,00h
                     mov bx,si
                     call checkEven
          	                  
                  
          mov ax,0x4c00
          int 0x21
          

          Q2. Write a code in assembly language (using appropriate jumps) equivalent to this given code in C. (10 Marks)
          #include <stdio.h>
          int main()
          {
          int n1=1, n2=2;
          int largest;
          if( n1>n2)
          largest=n1;
          else
          largest = n2;
          return 0;
          }

          Solution:

          Assembly code:

          [org 0x100]
          jmp start
          n1 db 1
          n2 db 2
          largest db 0
          
          start:
          	mov ax, [n1]
          	xor ah,ah
          	mov bx, [n2]
          	cmp ax,bx
          	ja large
          	mov [largest],bx 
          
          large:  mov [largest],ax
          
          
          mov ax, 0x4c00
          int 21h
          

          Discussion is right way to get Solution of the every assignment, Quiz and GDB.
          We are always here to discuss and Guideline, Please Don't visit Cyberian only for Solution.
          Cyberian Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
          NOTE: Don't copy or replicating idea solutions.
          Quiz Copy Solution
          Mid and Final Past Papers
          Live Chat

          1 Reply Last reply Reply Quote 0
          • zareen
            zareen Cyberian's Gold last edited by

            Discussion is right way to get Solution of the every assignment, Quiz and GDB.
            We are always here to discuss and Guideline, Please Don't visit Cyberian only for Solution.
            Cyberian Team always happy to facilitate to provide the idea solution. Please don't hesitate to contact us!
            NOTE: Don't copy or replicating idea solutions.
            Quiz Copy Solution
            Mid and Final Past Papers
            Live Chat

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Insaf Sehat Card Live Cricket Streaming

            100% Off on Your FEE Join US! Ask Me How?

            Quiz 100% Result If you want to know how you can join us and get 100% Discount on your FEE ask Cyberian in Chat Room!
            Quiz 100% Result Quiz 100% Result
            solution1255 discussion1206 fall 2019813 assignment 1433 assignment 2297 spring 2020265 gdb 1248 assignment 382 crw10174 spring 201955
            | |
            Copyright © 2021 Cyberian Inc. Pakistan | Contributors
            Live Chat