Homework 3

EECE.3170 Spring 2025

For the following questions, use the instructions and op-code for the ARMv6-M architecture as documented here and discussed in class:

https://developer.arm.com/documentation/ddi0419/c/Application-Level-Architecture?lang=en

Do not worry about pre-processor directives for this assignment. Focus on the assembly code snippets themselves.

  1. Arithmetic.
    1. (4 points) Write assembly code that computes the Fibonacci sequence (https://en.wikipedia.org/wiki/Fibonacci_sequence) to the tenth order. Specifically, use two registers to perform the operation. One should always have the highest value. The value of that register should go through the numbers 0, 1, 1, 2, 3, 5, 8, 13, 21, 34,55 (leading 0 is optional) throughout the process. When the process is complete, jump to the “next” label.
    2. (3 points) Convert the above assembly into op-code. Assume your code starts at 0x1000 and each instruction is 16-bits (half-word) long to calculate the position of labels. NOTE: in the actual ARMv6-M architecture, jumps must be done on word-aligned (e.g. even) instructions, but we will ignore that for right now.
  2. Status Register.
    1. (4 points) Write assembly code that computes the Fibonacci sequence (https://en.wikipedia.org/wiki/Fibonacci_sequence) until the 32-bit register overflows. Specifically, use two registers to perform the operation. One should always have the highest value. When the process overflows, jump to the “next” label.
    2. (3 points) Convert the above assembly into op-code. Assume your code starts at 0x1000 and each instruction is 16-bits (half-word) long to calculate the position of labels. NOTE: in the actual ARMv6-M architecture, jumps must be done on word-aligned (e.g. even) instructions, but we will ignore that for right now.
  3. Setting and getting bits.
    1. (8 points) Write assembly code that:
      – Sets bit 15 (counting from the right, 0 is the rightmost and 31 is the leftmost bit) of the word at memory address 0x5FFF15A4 to 1.
      – Waits until bit 15 of the word at memory address 0x5FFF3CB4 is set to 1.
      – NOTE: memory addresses are much larger than an 8-bit immediate can hold. Consider how to shift one byte in at a time. We will go over another method in the review.
    2. (8 points) Convert the above assembly into op-code. Assume your code starts at 0x1000 and each instruction is 16-bits (half-word) long to calculate the position of labels. NOTE: in the actual ARMv6-M architecture, jumps must be done on word-aligned (e.g. even) instructions, but we will ignore that for right now.