Week 3 Lab

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

CS211 Lab 2

Objectives

After completing this lab, students should be able to

 write, debug and execute simple machine language program


 understand machine execution cycle
 debug machine language program

Pre-Lab

Write a machine language program that prompts for two integers only, calculates and displays
the sum of the two integers, and exits.

Question 1

Write a machine language program which takes integers as input and computes the product of
integers entered. Your program should continue reading integers until user enters 0 (zero). 0
will act as a sentinel to indicate the end of input and it should not be included in the product
computation.

Question 2

Modify the program given in Lab 1 (sample.txt) to cater for negative numbers as well while
calculating the sum of the numbers entered. The program should terminate only when user
enters -99. Before terminating, the program should display the total sum to user. -99 is used as
sentinel and should not be included as part of calculation.

Programming Tip

In solving the above questions, it is advisable to write your initial program flow on paper,
preferably using decimal or symbolic names for instructions, before converting to machine
language (binary) instructions and executing the program on the simulator.

You might also like