This project involves writing small programs, modifying memory, printing to the console, and converting from high-level code to assembly.

  1. Odd vs Even To start off, I write a small assembly program to determine whether each element in the array (located in memory location x6000) is an odd or even number and print that to the console, as ODD or EVEN. If the element is zero, print ZERO to the console instead. I need to implement the odd/even check for an individual element in the array without using a loop - that means the odd/even/zero check for one given number should be O(1) (its runtime should not depend on the magnitude of the number) and thus the overall code should be O(n).

Ex: array: [9, 27, 64, 0] will produce this output:

ODD ODD EVEN ZERO

  1. Add-Subtract In this problem, I will iterate over items in an array (located at memory location x6000) and either add or subtract them, depending on their index (numbers at even indices will be added, and numbers at odd indices will be subtracted). Therefore, the element at index 0 will be added, the element at index 1 will be subtracted, the element at index 2 will be added, etc until I reach the end of the array. Once I have the result, I save it at the memory location given by the label RESULT.

Ex: array: [47, 36, 25, 9, 14, 11, 42] will result in

  • 47 - 36 + 25 - 9 + 14 - 11 + 42 = 72
  1. Reverse String The next problem is to reverse a string. I am given the memory address of the first character of a string and the length of the string. Reverse the string IN PLACE and make sure to maintain `\n' as the last character (so that it prints to the console via PUTS correctly). The trailing newline character is included in the character count. I assume that the last character will always be a newline.

Ex: string: \Ramblin Wrecknn" length: 14 will result in \kcerW nilbmaRnn".

  1. Number Triangle For this problem, I am given a number in the label TRIANGLE and will build a decreasing number triangle from it.

Built With

  • assembly
Share this project:

Updates