You are on page 1of 16

CE-207 Computer Organization & Architecture SSUET/QR/114

LAB 4
OBJECTIVE
To understand branching and simulate vvm programs using ”brp” , “brz” & “br” instructions.

LAB TASK
LAB TASK #1:
Take any integer as input.
▪ If the number is greater than 5, print the number.
▪ If the number is less than 5, halt.
▪ If the number is equal to zero, halt
SOURCE CODE:
CE-207 Computer Organization & Architecture SSUET/QR/114

OUTPUT:
HARDWARE VIEW:

TRACE VIEW:

LAB TASK #2:


CE-207 Computer Organization & Architecture SSUET/QR/114

Take two integers as input and subtract them.


If the result is positive, save and display it at the memory location of your roll number.

SOURCE CODE:
CE-207 Computer Organization & Architecture SSUET/QR/114

OUTPUT:
HARDWARE VIEW:

TRACE VIEW:

LAB TASK #3:


CE-207 Computer Organization & Architecture SSUET/QR/114

Take two numbers as input and print the smaller number.


SOURCE CODE:

OUTPUT:
CE-207 Computer Organization & Architecture SSUET/QR/114

HARDWARE VIEW:

TRACE VIEW:

LAB TASK #4:


CE-207 Computer Organization & Architecture SSUET/QR/114

Take three numbers as input like x1, x2, x3.


Then solve: x1 + x2 – x3.
If the result is 0, save and print the result at the memory location 50.

SOURCE CODE:

OUTPUT:
HARDWARE VIEW:
CE-207 Computer Organization & Architecture SSUET/QR/114

TRACE VIEW:

LAB TASK #5:


Write a VVM program which take an integer input and display table of that integer.
CE-207 Computer Organization & Architecture SSUET/QR/114

SOURCE CODE:

OUTPUT:
HARDWARE VIEW:
CE-207 Computer Organization & Architecture SSUET/QR/114

TRACE VIEW:

LAB TASK #6:


Design a simple loop using BRZ instruction in VVM.
CE-207 Computer Organization & Architecture SSUET/QR/114

SOURCE CODE:

OUTPUT:
HARDWARE VIEW:
CE-207 Computer Organization & Architecture SSUET/QR/114

TRACE VIEW:

LAB TASK #7:


Take any integer from user. If it’s positive, print the integer. Otherwise, program should be
closed. Repeat the task, the no. of times of the last digit of your roll no.
CE-207 Computer Organization & Architecture SSUET/QR/114

SOURCE CODE:

OUTPUT:
HARDWARE VIEW:
CE-207 Computer Organization & Architecture SSUET/QR/114

TRACE VIEW:

LAB TASK #8:


Take square of any integer in range (1-20).
SOURCE CODE:
CE-207 Computer Organization & Architecture SSUET/QR/114

OUTPUT:
HARDWARE VIEW:
CE-207 Computer Organization & Architecture SSUET/QR/114

TRACE VIEW:

You might also like