Need help understanding assignment for MARIE Assembly language

58 Views Asked by At

I've been tasked with solving a problem using the MARIE.JS website. I only wish to understand how I can approach this to solve it myself.

A program that after saving the data read from the sensor in memory, obtains the statistical average of the stored measurements. A second sensor is read that is going to send data at 12 bits / ms. The data from the sensors is sent one at a time through the same data input port, following the following structure.

Marie Data structure

The 16-bit input port is divided into data (DATA, bits 0 to 11) and selector (SEL, bit 15). If the selector is 0, the data comes from sensor one; otherwise, the data comes from the second sensor.

Finally, the average of each of the sensors can be delivered to MARIE's output port. For this, the display bit (bit 13 for sensor 1 and bit 14 for sensor 2) is used on the input port. If it is at 1, the mean of the selected sensor is displayed through the output port. The data will be kept until the other device is selected.

1

There are 1 best solutions below

0
On

In solving problems, we would apply experimentation, problem decomposition and solution prototyping.

In problem decomposition we would observe:

  • We need a statistical average

    This implies maintaining some state (i.e. one or more variables).  Such average likely requires a running total of values and a count of how many values have been seen.  An instantaneous or final average can be computed by dividing the two.  Some consideration needs to be given to integer overflow, so you need to know sample/maximum values for these variables.  (It would only take 17 sample 12-bit values to overflow a simple sum if each of those 17 were the maximum value in 12 bits.)

    We would write some pseudo code in C or other language you already know and save this algorithm / code snippet for later translation to assembly and insertion into the larger assembly program.

  • We need conditional testing: is the sensor data from sensor 1 or sensor 2.  Write a simple if-then-else that test the sensor data, and translate that into MARIE assembly.

  • You might experiment with the output portion.  It is somewhat unusual but not unheard of to repurpose an input port for output.  Compute the average as per above, then compose a word of data to write to that input port.  That word needs to have one of the high bits set.

  • It is not clear how to use the 12ms information.  You'll have to seek other help to understand if you're supposed to use polling or other.

    In a polling scenario, I suppose you could poll until the sensor changes from sensor 1 to sensor 2 (then take a sensor 2 reading) and then again changes from sensor 2 to sensor 1 (ignoring any further sensor 2 values).

    You might also re-read your assignment text as it would be more expected that SEL indicates when data is ready/not ready, and S1 vs. S2 says which sensor.

Once you've identified all the piece parts and figured how to make each one work independently, then put them all together into your program.