Pages created and updated by Terry Sturtevant Date Posted: May 12, 2017

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.

  1. 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
         IF K = 2 THEN
              B <- B + 1
              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.

  2. Write a program to find the smallest number in a list of unsigned numbers. Assume the length of the list is provided.

  3. 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.

  4. 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.

  5. 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.
Creative Commons License

Information on this site which is produced by Terry Sturtevant is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 Canada License.


To view pdf documents, you can download Adobe Acrobat Reader .
get Acrobat Reader
If you need to update a browser, you might try Firefox which is Get Firefox!
Since this page uses cascading style sheets for its layout, it will look best with a browser which supports the specifications as fully as possible.

If you are looking for an office package, with a word processor, spreadsheet, etc., you might try LibreOffice which is Get LibreOffice!

Go to the main page for the Department of Physics and Computer Science.

Valid XHTML 1.1

Valid CSS!

(Level AA)

Wilfrid Laurier University