CP316: Microprocessor Systems and Interfacing
Simple PIC18F452 Assembly Language Programs
The objective of this assignment is to get you
comfortable coding decision structures and loops in the PIC assembly language. It
will also give you practice with the MPLAB IDE. The board is not required
and you could do these questions at home.
Do NOT hand this assignment in. No demonstration required.
-
Write the code for the following program segment. Assume the tests use
unsigned arithmetic. Verify your program works by doing exhaustive path
testing. In other words, run the program sufficient times to demonstrate
each of the possible paths through the program segment. Remember to consider
the case when the program segment is not executed.
IF K = 1 THEN
A <- A + 1
ELSE
IF K = 2 THEN
B <- B
+ 1
ELSE
C <- C
+ 1
END IF
END IF
For the following questions, use literal addressing to first load
up a series of memory locations with the required data and then manipulate
it as specified.
- Write a program to find the smallest number in a list of unsigned numbers.
Assume the length of the list is provided.
- Write a program to determine the number of zero, positive, and negative
elements in a series of signed numbers. Assume the length of the list is
provided.
- Write a program to calculate the checksum of a series of 8-bit numbers.
The checksum is formed by doing an exclusive OR of all the numbers
in the list. For example, if the series had three numbers: $28, $55, and
$26, the checksum would be formed by $28 XOR $55 XOR $26.
The checksum for the example would be $5B. Assume the length of the list
is provided.
- Write a program to determine which element in a series of 8-bit numbers
has the largest number of bits that are one. Assume the list is null terminated.
Wilfrid Laurier University
© 2019 Wilfrid Laurier University