You are on page 1of 3

EE3333

Assignment #4

EE3333: Microprocessor Interfacing

Assignment # 4
(Due-Date: Sec-1,Sec-2: January 24, 2011, Due in Class) (Due-Date: Sec-3: January 25, 2011, Due in Class)

NOTE: This is an individual assignment. You have to submit it in handwriting. No Computer print outs will be accepted. No Late Submission is allowed!!

Q # 1.

(a). Write Sequence of 8086 Assembly Instructions that will implement same functionality as (10-Points) following C-Code Segment

// C-Code if (val1 > val2) X = 1; else if(val1 <=val2) X = 2 else X = 3; }

(b). Write Sequence of 8086 Assembly Instructions that will implement same functionality as (10-Points) following C-Code
//C-Code while(val1 < val2) { val1++; if (val2==val3) X=2; else X=3; }

(c). Write a complete assembly program that loads marks of a student as an immediate value in
register AX ( 0 <= Marks <= 100) . Program will assign letter grade according to following grading scheme. ASCII Code for assigned grade should be in register BX.

(10-Points)

Page 1 of 3

EE3333 If Marks >= 80 , Grade = A If Marks >= 70 , Grade = B If Marks >= 60 , Grade = C If Marks >= 50 , Grade = D If Marks < 50 , Grade = F

Assignment #4

Q #2.

(10 + 10 Points)

(a). Write a complete assembly program that allocates following array as 16-bit data in data segment. Program will find average of array and will store result back in data segment. Array [10] = {100, 50, 90, 15, 210, 75, 125, 39, 45, 20 } (b). Write a complete assembly program that allocates following two arrays as 8-bit data in data segment. Program will compute dot-product of arrays according to formula given below and will store result back in data segment.
Dot _ Pr oduct = x[k ] * y[k ]
k =0 N 1

Array1 [10] = {10, 50, 19, 15, 21, 75, 15, 39, 34, 20 } Array2 [10] = {15, 25, 30, 15, 22, 17, 12, 9, 5 , 33 }

Q #3.

(15 + 15 Points)

(a). Convert the following C Language Program into 8086 Assembly Language Program. Assembly Program will implement addnums() as a separate subroutine and will Call it from main subroutine. Main subroutine will allocate data in data segment.
//C Program to add two numbers short addnums (short val1, short val2, short val3 ) { short temp; temp = val1 + val2 + val3; return temp; }

Page 2 of 3

EE3333 //

Assignment #4 Contd

void main() { short num1,num2,num3, result; num1 = 50; num2 = 90; num3 = 30; result = addnums(num1,num2, num3); }

(b). Write an assembly subroutine that takes a number as single argument and returns its factorial. Write a main subroutine that will load an immediate value <= 8 in register BX and will compute its factorial using your factorial Subroutine.

Q # 4.

(10 + 10 Points)

(a). Allocate following array in data segment as 16-bit data. Allocate space for another array array2 of same size in data segment. Write an Assembly Program that copies elements of array1 into array2 starting from the last element of array1. Program should use string instruction movs to accomplish the task.

Array1 [20] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 15, 25, 35, 45, 55, 65, 75, 85, 95, 34, 20 }
(b). Allocate following character string in data segment. Write an assembly program that scans the string of characters to find character a. If found it copies its position within string in register DX, otherwise it copies -1 in DX. Program should use 8086 string instructions String = cccddeeafgijklm

Page 3 of 3

You might also like