0% found this document useful (0 votes)
83 views

Computer Architecture and Assembly Language Programming - CS401 Fall 2006 Assignment 02 Solution

This document provides instructions for Assignment #02 for the course CS 401 Computer Architecture and Assembly Language Programming. It states that the assignment is due on October 29, 2006 and provides directions for uploading the completed assignment. It outlines rules for grading, including penalties for late or plagiarized submissions. The objective is to demonstrate knowledge of logical shift instructions, bitwise logical operations, and comparison/condition operations. It presents two questions - the first asks to write a program to find the minimum and maximum numbers in an array, and the second asks to determine the results of performing various shift and rotate operations on a value in the AL register.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views

Computer Architecture and Assembly Language Programming - CS401 Fall 2006 Assignment 02 Solution

This document provides instructions for Assignment #02 for the course CS 401 Computer Architecture and Assembly Language Programming. It states that the assignment is due on October 29, 2006 and provides directions for uploading the completed assignment. It outlines rules for grading, including penalties for late or plagiarized submissions. The objective is to demonstrate knowledge of logical shift instructions, bitwise logical operations, and comparison/condition operations. It presents two questions - the first asks to write a program to find the minimum and maximum numbers in an array, and the second asks to determine the results of performing various shift and rotate operations on a value in the AL register.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

CS 401 Computer Architecture and Assembly Language

Programming
Assignment #02
Deadline
Your assignment must be uploaded / submitted before or on October 29, 2006.

Upload Instructions
Please view the assignment submission process document provided to you by the Virtual
University to upload the assignment.

Rules for Marking


Please note that your assignment will not be graded if:
It is submitted after due date
The file you uploaded does not open
The file you uploaded is copied from some one else
It is in some format other than .doc

Objective
The assignment has been designed to enable you:

To know about logical shift instructions manipulations.


To know about the bitwise logical operations.
To know about the comparison and conditions

Answer the following questions


Q#1
Write a program in Assembly Language to find the maximum number and the minimum
number from an array of ten numbers.
Solution:
[org 0x0100]
jmp start
; unconditionally jump over data
array1:
min:
max:

dw 10, 5, 30, 4, 50, 1, 20, 6, 40, 8


dw 0
dw 0

start:
;---------------for finding minimum number
mov bx, 0
; initialize array index to zero
mov ax, 0
; initialize min to zero

top1:

mov ax, [array1+bx]


mov cx,10

; minimum number to ax

cmp ax, [array1+bx]


jle end1
mov ax,[array1+bx]

; are we find the minimum number


; if less or equal number
;ax contains the minimum number

end1:
add bx, 2
loop top1
mov [min], ax

; advance bx to next index


; write back minimum in memory

;----------------for maximum number


mov bx, 0
; initialize array index to zero
mov ax, 0
; initialize max to zero
mov ax, [array1+bx] ; maximum number to ax
mov cx,10
top2:

cmp ax, [array1+bx] ; are we find the maximum number


jge end2
; if greater or equal number
mov ax,[array1+bx] ;ax contains the maximum number

end2:
add bx, 2
loop top2
mov [max], ax
mov ax, 0x4c00
int 0x21

; advance bx to next index


; write back maximum number in memory
; terminate program

Q#2
Suppose AL contains 10011011b and CF= 0. Give the new contents of AL after each of
the following instructions is executed. Assume the preceding initial conditions for each
part of this question.
a. SHL AL,1
b. SHR AL, CL if CL contains 3

c. ROL AL ,1
d. SAR AL, CL if CL contains 3
e. RCR AL,CL if CL contains 2
Solution:
a.
b.
c.
d.
e.

AL=00110110
AL=00010011
AL=00110111
AL=11110011
AL=10100110

CF=1
CF=0
CF=1
CF=0
CF=1

You might also like