Question: . data # Define data structures test _ struct: . space 3 2 # Assuming each test takes 3 2 bytes ( 7 for ID

.data
# Define data structures
test_struct: .space 32 # Assuming each test takes 32 bytes (7 for ID,10 for name, 7 for date, 8 for result)
test_count: .word 0
patient_ids: .space 4000 # Array to store patient IDs (1000*4 bytes per ID)
test_names: .space 10000 # Array to store test names (1000*10 bytes per name)
test_dates: .space 7000 # Array to store test dates (1000*7 bytes per date, assuming YYYY-MM format)
test_results: .space 8000 # Array to store test results (1000*8 bytes per result, assuming float)
buffer: .space 512
search_all_header: .asciiz "Patient ID\tTest Name\tTest Date\tTest Result
"
separator: .asciiz "\t"
newline: .asciiz "
"
# Define constants for normal ranges
Hgb_min: .float 13.8
Hgb_max: .float 17.2
BGT_min: .float 70
BGT_max: .float 99
LDL_max: .float 100
BPT_systolic_max: .float 120
BPT_diastolic_max: .float 80
# Define constants for menu options
add_option: .asciiz "1. Add a new medical test
"
search_option: .asciiz "2. Search for a test by patient ID
"
average_option: .asciiz "3. Average test value
"
update_option: .asciiz "4. Update an existing test result
"
delete_option: .asciiz "5. Delete a test
"
exit_option: .asciiz "6. Exit
"
menu_prompt: .asciiz "Enter your choice: "
search_options: .asciiz "Search Options:
1. Retrieve all patient tests
2. Retrieve all abnormal patient tests
3. Retrieve all patient tests in a specific period
Enter your choice: "
no_tests_found_message_text: .asciiz "No tests found.
"
invalid_option_message: .asciiz "Invalid option. Please enter a valid choice.
"
filename: .asciiz "test.txt"
# Prompts for user input
prompt_patient_id: .asciiz "
Enter Patient ID (7 digits):
"
prompt_test_name: .asciiz "
Enter Test Name:
"
prompt_test_date: .asciiz "
Enter Test Date (YYYY-MM):
"
prompt_result: .asciiz "
Enter Test Result:
"
invalid_patient_id_message: .asciiz "Invalid patient ID. Please enter exactly 7 digits.
"
invalid_test_name_message: .asciiz "Invalid test name. Please enter a name of 4 characters or less.
"
invalid_test_date_message: .asciiz "Invalid test date format. Please enter date in YYYY-MM format.
"
invalid_test_result_message: .asciiz "Invalid test result. Please enter a valid numerical value.
"
# Variables to store user input
user_patient_id: .space 8 # Buffer to store patient ID
user_test_name: .space 4 # Buffer to store test name
user_test_date: .space 8 # Buffer to store test date
user_result: .space 5 # Buffer to store test result
.text
main:
# Display menu
li $v0,4
la $a0, add_option
syscall
li $v0,4
la $a0, search_option
syscall
li $v0,4
la $a0, average_option
syscall
li $v0,4
la $a0, update_option
syscall
li $v0,4
la $a0, delete_option
syscall
li $v0,4
la $a0, exit_option
syscall
li $v0,4
la $a0, menu_prompt
syscall
# Get user input for menu option
li $v0,5
syscall
move $t0, $v0 # Store user choice in $t0
# Branch to corresponding function based on user choice
beq $t0,1, add_test
beq $t0,2, search_test
beq $t0,3, average_test_value
beq $t0,4, update_test_result
beq $t0,5, delete_test
beq $t0,6, exit_program
j main # If invalid choice, display menu again
add_test:
# Prompt and get user input
la $a0, prompt_patient_id
li $v0,4
syscall
li $v0,8
la $a0, user_patient_id
li $a1,8
syscall
la $a0, prompt_test_name
li $v0,4
syscall
li $v0,8
la $a0, user_test_name
li $a1,4
syscall
la $a0, prompt_test_date
li $v0,4
syscall
li $v0,8
la $a0, user_test_date
li $a1,8
syscall
la $a0, prompt_result
li $v0,4
syscall
li $v0,8
la $a0, user_result
li $a1,5
syscall
# Format the data in buffer
la $t0, user_patient_id
la $t1, user_test_name
la $t2, user_test_date
la $t3, user_result
la $t4, buffer
# Copy Patient ID
copy_loop_patient_id:
lb $t5,0($t0)
beqz $t5, end_copy_patient_id
sb $t5,0($t4)
addi $t0, $t0,1
addi $t4, $t4,1
j copy_loop_patient_id
end_copy_patient_id:
li $t6,':' # Add ':' after Patient ID
sb $t6,0($t4)
addi $t4, $t4,1
li $t6,'' # Add space after comma
sb $t6,0($t4)
addi $t4, $t4,1
# Copy Test Name
copy_loop_test_name:
lb $t5,0($t1)
beqz $t5, end_copy_test_name
sb $t5,0($t4)
addi $t1, $t1,1
addi $t4, $t4,1
j copy_loop_test_name
end_copy_test_name:
li $t6,',' # Add ',' after Test Name
sb $t6,0($t4)
addi $t4, $t4,1
li $t6,'' # Ad this is my code i need a code for delete and updatae and search i need a code in mips not steps please

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!