1007ICT
Computer Systems & Networks
Lab 6 (3%), due Week 10
On a computer, create and run a 6800 program which computes the problem allocated to
you on the other side of this page. When you have tested and run your program please
demonstrate to your tutor.
Here are the questions – please see the other side of this page to find out which question
you must attempt (you only have to do one question: either A, B, or C).
Question A
Write a program to determine if a number is prime. A prime number only has 2 factors:
itself and 1. For example, the number 12 has 6 factors (1, 2, 3, 4, 6, 12) so it is not prime.
However, 3 is a prime number, since it’s only factors are 3 and 1. Your program should store
the number to check as a variable and then set a variable called isPrime to 1 if the variable is
prime, otherwise 0. So if num is 3, before the program runs the pre-stored variables will be:
num .byte 3
isPrime .byte 0
and after the program runs, the variables will be:
num .byte 3
isPrime .byte 1
This is because 3 is prime. If the number is not prime, then set isPrime to 0.
Question B
Write a program to count how many factors an input variable has. For example, the number
12 has 6 factors (1, 2, 3, 4, 6, 12). Your program should store the number to check as a
variable and then store the number of factors in a variable called numFactors. So if num is
12 then before the program runs the pre-stored variables will be:
num .byte 12
numFactors .byte 0
and after the program runs, the variables will be:
num .byte 12
numFactors .byte 6
Question C
Write a program to determine the greatest common divisor (GCD) between two numbers.
Here is an explanation of GCD: https://www.khanacademy.org/math/cc-sixth-grade-
math/cc-6th-factors-and-multiples/cc-6th-gcf/v/greatest-common-divisor
Use these variables:
p .byte 15
q .byte 12
and after the program runs, the answer will be:
gcd .byte 3
this is because the greatest number which divides into both 15 and 12 is 3.
Student Question
Cody A
Jamie B
Nhat Anh C
Haonan A
Xingweiai B
Ben C
Jui-Teng A
Wai Chun B
Wyatt C
Joshua A
Benedict B
Danny C
Jone A
Xitao B