CS508 Assignment #5 - Memory Access, Integer Arithmetic

Question # 00856624 Posted By: wildcraft Updated on: 06/26/2024 02:31 AM Due on: 06/26/2024
Subject Computer Science Topic General Computer Science Tutorials:
Question
Dot Image

CS 508

Computer Organization and Design

Assignment #5

Memory Access, Integer Arithmetic and Logic Operations

This assignment will expand on assembly language programming by having you create a sequential program that applies arithmetic and logic operations on numeric data.

Part 1: Data Definitions

For this assignment, there are only three data items to define as follows:

num1: .half 0xabcd # a 16-bit halfword for logic operations to be applied

nmask: .half 0x000f # a mask for a 4-bit nibble

bmask: .half 0x00ff # a mask for an 8-bit byte

No additional values are to be defined in the data segment. You will need to know the offset values for these items to be loaded into registers, but you are not required to state them in the comments.

 

Part 2: Arithmetic and Logic Operations (nibble values)

 

The program will utilize a number of registers so you will want to have a register usage plan defined so that your use of registers is organized and logical. The first instructions in the text segment should be to load the three data values into registers.

 

The next sequence of instructions should apply the appropriate mask to extract each 4-bit nibble from num1. The following image shows the application of this masking and bit extraction technique.

 

 

 

(original mask value)

 

 

 

 

 

(adjusted mask value)

 

Note in the image that the mask value is shifted to align with the bits of the nibble being extracted from num1. This shifting must be done in code using the appropriate logic instruction for the extraction of each nibble a – c. Each extracted nibble must be in a separate register. The mask value can remain in the same register that it was loaded (shift in place).

 

To complete the first sequence of operations, the four extracted nibbles are to be added to produce a sum. So effectively, you are performing the operation a + b + c + d. However, prior to adding the values, they must be shifted into the low order bits of their respective registers so that the place values align. The sum will be placed in its own register, thus preserving the extracted nibble values.

 

Part 3: Arithmetic and Logic Operations (byte values)

 

The last part of the program will have you perform an extraction of the two bytes from num1. The following image shows the basic concept.

 

 

 

 

(original mask value)

 

 

 

 

(adjusted mask value)

 

 

Note the shifting of the mask as was done in the previous part which must be done in code. Each byte should be extracted to different registers. Once again, the mask can be shifted in place using the same register.

 

After extracting each byte, perform a right shift on the second value to align it in the lower order byte position. After the alignment shift, subtract the second extracted byte from the first and place the value in a separate register, retaining the extracted bytes in their original registers.

 

Finally, add the result of the sum of the nibbles in part 1 with the result of subtracting the two bytes, placing the result in another available register. Verify that the correct value has been produced.

 

Your program should be well documented with comments including the required register usage section preceding the data segment of the program and after the header comment section. Submit your final source code program on Blackboard.

 

Grading Criteria:

 

Inclusion of ter Usage List 5 points

Correct syntax/format for all instructions 10 points

Correct logic (sequencing) of instructions 15 points

Loading appropriate values from memory (correct offsets) 5 points

Appropriate comments 5 points

Correct program results 5 points

Total points for assignment 45 points

image1.png

image2.png

Dot Image
Tutorials for this Question
  1. Tutorial # 00852113 Posted By: wildcraft Posted on: 06/26/2024 02:32 AM
    Puchased By: 2
    Tutorial Preview
    The solution of CS508 Assignment #5 - Memory Access, Integer Arithmetic...
    Attachments
    CS508_Assignment_5_-_Memory_Access,_Integer_Arithmetic.ZIP (18.96 KB)

Great! We have found the solution of this question!

Whatsapp Lisa