[SOLVED] CS计算机代考程序代写 #############################################################

30 $

File Name: CS计算机代考程序代写_#############################################################.zip
File Size: 857.22 KB

SKU: 9317557292 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


#############################################################
#DO NOT MODIFY THIS FILE IN ANY WAY!!!
#############################################################

#############################################################
#This data block contains all of the inputs and outputs
#necessary to summarize the final grades component of the
#output.
#############################################################

.data
testset_format:.asciiz “Beginning to run tests to count the number of format specifiers.


testset_intconv: .asciiz “Beginning to run tests to check the integer conversion to string.


testset_sprintf: .asciiz “Beginning to run tests to verify the correctness of sprintf().

menu_lead: .asciiz “Which function(s) are you ready to test?[0-3]

menu_all:.asciiz ”0.All of them

menu_first: .asciiz ”1.Count format specifiers

menu_second: .asciiz ”2.Convert int to string

menu_third: .asciiz ”3.sprintf

invalid_input: .asciiz “Invalid selection.Try running again and entering a number 0-3.”

break: .asciiz “

—————————————————-


final_score: .asciiz “Your final scores are:

format_score:.asciiz ”Number of format specifiers:”
conv_score:.asciiz ”Converting int to string: ”
sprintf_score: .asciiz ”Correctness of sprintf(): ”

slash_max: .asciiz “/100

slash_max2:.asciiz “/200

newline_main:.asciiz “

.text

.globl main

#############################################################
#The code below calls the three testing procedures from
#the tests.asm file, stores, and outputs the total points
#earned from this assignment.
#############################################################

main:

# Print menu
la $a0, menu_lead
li $v0, 4
syscall

la $a0, menu_all
syscall

la $a0, menu_first
syscall

la $a0, menu_second
syscall

la $a0, menu_third
syscall

# Get user input
li $v0, 5
syscall

# Validate that it’s between 0-3 inclusive
blt $v0, $zero, BAD_INPUT
bgt $v0, 3, BAD_INPUT
j AFTER_BAD_INPUT

BAD_INPUT:
la $a0, invalid_input
li $v0, 4
syscall

j EXIT

AFTER_BAD_INPUT:
# $t6 will store the user option
move $t6, $v0

# Jump to next test if user option == 2 or 3
beq $t6, 2, BEFORE_CONVERT_INT
beq $t6, 3, BEFORE_CONVERT_INT

# Back up user test option before calling the tests
subi $sp, $sp, 4
sw $t6, 0($sp)

# Run tests for number of format specifiers
la $a0, testset_format
li $v0, 4
syscall

jal PROC_TEST_COUNT_FORMAT_SPECIFIERS

# Recover user option
lw $t6, 0($sp)
addi $sp, $sp, 4

# put number of points for format specifiers into $t9
move $t9, $v0

BEFORE_CONVERT_INT:

# Jump to next test if user option == 1 or 3
beq $t6, 1, BEFORE_SPRINTF
beq $t6, 3, BEFORE_SPRINTF

# Back up points so far & user option before calling the next set of tests
subi $sp, $sp, 8
sw $t9, 0($sp)
sw $t6, 4($sp)

jal PROC_TEST_CONVERT_INT_TO_STRING

# Recover points earned so far
lw $t9, 0($sp)
lw $t6, 4($sp)
addi $sp, $sp, 8

# put number of points for conversion into $t8
move $t8, $v0

BEFORE_SPRINTF:

# Jump to print points if user option == 1 or 2
beq $t6, 1, PRINT_POINTS
beq $t6, 2, PRINT_POINTS

# Run tests for number of format specifiers
la $a0, testset_sprintf
li $v0, 4
syscall

# Back up points so far & user option before calling the next set of tests
subi $sp, $sp, 12
sw $t9, 0($sp)
sw $t8, 4($sp)
sw $t6, 8($sp)

jal PROC_TEST_SPRINTF

# Recover points earned so far
lw $t9, 0($sp)
lw $t8, 4($sp)
lw $t6, 8($sp)
addi $sp, $sp, 12

# put number of points for sprintf into $t7
move $t7, $v0

PRINT_POINTS:
# output final grades
la $a0, break
li $v0, 4
syscall

la $a0, final_score
syscall

FORMAT_SPEC_GRADE:
# Jump to next points output if user option == 2 or 3
beq $t6, 2, INT_TO_STRING_GRADE
beq $t6, 3, INT_TO_STRING_GRADE

# format specifiers score
la $a0, format_score
syscall

move $a0, $t9
li $v0, 1
syscall

la $a0, slash_max
li $v0, 4
syscall

INT_TO_STRING_GRADE:
# Jump to next points output if user option == 1 or 3
beq $t6, 1, SPRINTF_GRADE
beq $t6, 3, SPRINTF_GRADE

# integer to string conversion score
la $a0, conv_score
syscall

move $a0, $t8
li $v0, 1
syscall

la $a0, slash_max
li $v0, 4
syscall

SPRINTF_GRADE:
# Jump to exit if user option == 1 or 2
beq $t6, 1, EXIT
beq $t6, 2, EXIT

# sprintf score
la $a0, sprintf_score
syscall

move $a0, $t7
li $v0, 1
syscall

la $a0, slash_max2
li $v0, 4
syscall

EXIT:
# terminate program cleanly
li $v0, 10
syscall

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS计算机代考程序代写 #############################################################
30 $