Cs302 2nd Assignment Solution Cs401

CS401 Assignment No 2 Spring 2017

Here you can read and Download CS401- Computer Architecture and Assembly Language Programming Assignment No 2 Spring 2017 Solution and Discussion. Assignment Total marks = 20. CS401 Assignment No 2 Deadline Date 16 May, 2017. Previously we shared CS401 Assignment No 1 Solution Spring 2017.
CS401 Assignment No 2 Spring 2017 Solution and Discussion
Recommended:CS401 Mid Term Past Papers / Notes

You Can Also Download CS401 Mid Term Papers,CS401 Short Notes, CS401 Assignment Solutions, CS401 Lecture Wise Questions Answers Files, CS401 Solved MCQs, CS401 Solved Quiz , CS401 Solved Mid Term Subjective Papers , CS401 Mid Term Objective Papers from Virtual Study Solutions For Preparation of Mid Term Papers.

Topic Covered in CS401 Assignment:

  • Branching
  • Unconditional Jumps & Relative Addressing
  • Bit Manipulation
  • Multiplication
  • Bitwise Operations & Masking Operations
Recommended : CS401 All Final Term Past Papers

CS401 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 consult 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.
Recommended :C++ Programming basic Concepts and Questions

CS401 Assignment 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: cs401@vu.edu.pk

CS401 Assignment Question

Marks = 20

An arithmetic progression (AP) or arithmetic sequence is a sequence of numbers such that the difference between the consecutive terms (An-1& An) is constant “d”.

You are required to write assembly language code that has two different subroutines:
1 - Subroutine to generate an Arithmetic Sequence

You will have to write a subroutine named as “A_Sequence”, which will use some local variables “ASeq” & “Ddiff”.
  • Where the “Ddiff” is a data word contains Dh (0xD). 
  • The Arithmetic Sequence “ASeq” will start from a decimal number 3. 

This subroutine will generate first 10 terms of Arithmetic Sequence (ASeq). So, Arithmetic Sequence (ASeq) will be shown as:

2 - Subroutine to find the Arithmetic Sequence Term.

You will have to write a subroutine named as “N_Term”. In this subroutine, while using the Arithmetic Sequence (ASeq) and (Ddiff) from previous subroutine, you are required to find the value of 23rd term of arithmetic sequence.
Recommended :How to write C++ Program to make a Simple Snake Game

CS401 Assignment No 2 Solution Spring 2017

CS401 Assignment No 2 solution

[org 0x0100]

jmp start

number: db02


multiplier: db0

multiResult: dw0


square: mov[multiplicand], AX

mov[multiplier], AXcallmult

movAX,[multiResult]mov[squareResult], AX


multi: movCL,8


carryCheck: shr BX, 1jncskip


skip: shl BX, 1



start: movAX,[number]

call square



1addDX, AX

add byte[number],




2call multi


shrDX,1 ; divisionby2

movAX,0x4c00 ;ending programint0x21

Download Link for CS401 Assignment No 2

Please Subscribe below or Like us on Facebook. Thank You.

Question no. 1:

(a)  Assemble the following instructions and show the changes in given Accumulator register and flags after each instruction execution.                                                                                           (Marks 5)

MOV AL, 8Bh                       ; CF = ?, SF = ?, PF = ?, ZF = ?

ADD AL, 22h                         ; CF = ?, SF = ?, PF = ?, ZF = ?        

AND Al, 1000101b                ; CF = ?, SF = ?, PF = ?, ZF = ?

OR Al, 9Ah                            ; CF = ?, SF = ?, PF = ?, ZF = ?

XOR AL, 10101011b             ; CF = ?, SF = ?, PF = ?, ZF = ?

TEST AL, 2                            ; CF = ?, SF = ?, PF = ?, ZF = ?

CMP AL, 58                           ; CF = ?, SF = ?, PF = ?, ZF = ?

ADC AL, 11110000b             ; CF = ?, SF = ?, PF = ?, ZF = ?

SHR AL,2                               ; CF = ?, SF = ?, PF = ?, ZF = ?

Question no. 1 (b):                                                                                                                     (Marks 5)

Write a subroutine that can calculate the sum of an array and also save the result into DX.

( Array’s length is 20)

Question no. 2

Write an assembly language code to calculate the factorial of “7” using a subroutine and also attach the final snapshot of your AFD window.                       

                                                                                                                                                  ( Marks:10)


Leave a Reply

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