This project implements a RISC-V assembly program that processes a series of list manipulation commands provided as a single input string. The input string, declared as listInput in the .data section, contains commands separated by the ~ character (ASCII 126). The main function and associated functions handle commands to add, delete, print, sort, and reverse elements in a list.
- ADD(char): Adds a new element with
DATA=charto the end of the list. - DEL(char): Searches for and removes the first occurrence of an element with
DATA=charfrom the list. - PRINT: Prints all elements in the list in their current order.
- SORT: Sorts the list in ascending order.
- REV: Reverses the order of the list elements.
- The input string,
listInput, can contain up to 30 commands. - Commands are separated by the
~character. - The program performs validation checks on the commands to ensure proper formatting and valid operations.
- ADD and DEL Commands: Must contain exactly one character within parentheses (e.g.,
ADD(a)orDEL(b)). Commands with zero or multiple characters in parentheses are considered malformed and are discarded. - Case Sensitivity: Commands must be in uppercase letters (e.g.,
PRINTis valid, butprintis not). - No Spaces in Commands: Commands must not contain spaces within the command word (e.g.,
SORTis valid, butSO RTis not). However, spaces adjacent to the~separators are tolerated. - Examples:
- Valid:
ADD(a)~DEL(b)~PRINT~SORT~REV - Invalid:
AD D(a)~DE L(b)~print~SO RT~REV
- Valid:
- Main Function: Processes the input string, delegates commands to respective functions, and handles overall list management.
- Helper Functions: Implement the logic for each command (ADD, DEL, PRINT, SORT, REV) and any additional necessary operations.
- Place the
listInputstring in the.datasection of the RISC-V assembly code. - Ensure the input string follows the specified format and constraints.
- Run the program to see the list manipulation based on the commands provided in
listInput.
listInput: .string "ADD(a)~ADD(b)~PRINT~SORT~PRINT~REV~PRINT"
- Initial Input:
ADD(a)~ADD(b)~PRINT~SORT~PRINT~REV~PRINT - Output:
a b ----- a b ----- b a
This README description outlines the functionality, input handling, command format, and usage of the RISC-V assembly project for processing list commands.
You can download the complete documentation here. The repository is available here for browsing all the project resources.
