Explore BrainMass

An Assembly Language Program

Design and write an assembly language program for the MARIE processor that counts the number of occurrences of a particular word value in an array of words.

This program must perform the required function and must satisfy the following requirements.

a) The first instruction of the program must be placed at location (address) 0x100 (100 hexadecimal) in MARIE's memory.

b) Use constant data values (One, Words, Key, and Base) that should not be changed by the program. The program can load from these memory locations, but should not store to them. The array of word values that are to be processed by the program should be in successive memory locations beginning at location Array. The program should not change any of the data values in the array. These values should all be "hard-coded" into the program. Ensure that you set the value in location Base depending on where the assembler places the array, as indicated in the listing file.

c) The program should work for any value in location Words and Key and for any set of values in the array of words, not just those provided in your solution, so test the program thoroughly with different values. The value in location Words must be greater than or equal to 1.

d) The program must place the final value for the count of matching words in location Match.

e) The program must use a loop and indirect addressing to access the values in the array of words. Use meaningful loop variables names like Ptr, Cnt, and Match in the loop.

f) The program should always initialize the values for Cnt, Ptr, and Match in the working data memory and not rely on the values for these locations that are defined in the assembly source file.

Solution Preview

Please refer to the attached 589231-wordcount.mas (Marie program) that implements the following loop logic.

Cnt = Words
Ptr = Base (i.e. &Array[0])
Match = 0

if (*Ptr == Key)

Solution Summary

Solution provides a high-level operation of the program including initialization and operation of the loop using C like pseudocode, and later implements that logic in MARIE assembly language. It also provides a brief guidance as to how user can test the program with different values.