Answered Essay: Can someone try to fix this code ?? Thank you.

Can someone try to fix this code ?? Thank you.

1) Write a program that asks user how many positive number that is devisable by you want to add?”·Then your loop counter would be the user input. If the user enters a positive number between 1 and 100 that is devisable by 6, you increment your loop counter and add it to the sum. You need to decide if the positive number entered by the user is divisible by 6 or not. Your program should print an error message if the number is not within the range and ask user for another number An Example of sample input and output would be How many positive number that is devisable by you want to add? Enter a number: 36 36 is divisible by 6 Enter a number: -20 ****ERROR: -20 is not a positive number. Enter another number Enter a number:0 **ERROR: 0 is not in the range of 1 to 100. Enter another number. Enter a number: 21 21 is not divisible by 6. Enter another number Enter a number: 121 ERROR: 121 is not in the range of 1 to 100, Enter another number. Enter a number:6 6 is divisible by 6 Enter a number: 12 12 is divisible by 6 The Sum of the positive numbers between 1 and 100 that are devisable by 6, is: 54

.data
Prompt: .asciiz “How many positive number that is devisable by you want to add? ”
Prompt1: .asciiz “Enter a number: ”
NewLine: .asciiz “n”
Error: .asciiz “****Error: ”
Success: .asciiz ” is divisible by 6″
Fail: .asciiz ” is not divisible by 6″
RestMessage: .asciiz ” is not in the range of 1 to 100.”
RestMessage1: .asciiz ” is not a positive number”
Result: .asciiz “The Sum of the positive numbers between 1 and 100 that are devisable by 6, is: ”

.text
Main:
addi $t6, $zero, 6
la $a0, Prompt
addi $v0, $zero, 4
syscall

addi $v0, $zero, 5
syscall

jal PrintNewLine

move $s0, $v0
addi $s1, $zero, 0
Loop:
la $a0, Prompt1
addi $v0, $zero, 4
syscall

addi $v0, $zero, 5
syscall
move $t0, $v0
blt $t0, 0, Lt
bgt $t0, 100, Gt

Else: div $t0, $t6
mfhi $t1
bne $t1, 0, No
Yes: add $s1, $s1, $t0
add $s0, $s0, 1
move $a2, $t0
jal PrintSuccess
jal PrintNewLine
b End
No: move $a2, $t0
jal PrintFail
jal PrintNewLine
End:
b Here
Lt: move $a2, $t0
la $a3, RestMessage1
jal PrintError
jal PrintNewLine
b Here
Gt: move $a2, $t0
la $a3, RestMessage
jal PrintError
jal PrintNewLine
Here:
addi $s0, $s0, -1
bne $s0, 0, Loop

la $a0, Result
addi $v0, $zero, 4
syscall

move $a0, $s1
addi $v0, $zero, 1
syscall

addi $v0, $zero, 10
syscall

PrintError: la $a0, Error
addi $v0, $zero, 4
syscall

move $a0, $a2
addi $v0, $zero, 1
syscall

move $a0, $a3
addi $v0, $zero, 4
syscall

jr $ra

PrintSuccess: move $a0, $a2
addi $v0, $zero, 1
syscall

la $a0, Success
addi $v0, $zero, 4
syscall

jr $ra

PrintFail: move $a0, $a2
addi $v0, $zero, 1
syscall

la $a0, Fail
addi $v0, $zero, 4
syscall

jr $ra

PrintNewLine: la $a0, NewLine
addi $v0, $zero, 4
syscall
jr $ra

Show transcribed image text1) Write a program that asks user “how many positive number that is devisable by you want to add?”·Then your loop counter would be the user input. If the user enters a positive number between 1 and 100 that is devisable by 6, you increment your loop counter and add it to the sum. You need to decide if the positive number entered by the user is divisible by 6 or not. Your program should print an error message if the number is not within the range and ask user for another number An Example of sample input and output would be How many positive number that is devisable by you want to add? Enter a number: 36 36 is divisible by 6 Enter a number: -20 ****ERROR: -20 is not a positive number. Enter another number Enter a number:0 **ERROR: 0 is not in the range of 1 to 100. Enter another number. Enter a number: 21 21 is not divisible by 6. Enter another number Enter a number: 121 ERROR: 121 is not in the range of 1 to 100, Enter another number. Enter a number:6 6 is divisible by 6 Enter a number: 12 12 is divisible by 6 The Sum of the positive numbers between 1 and 100 that are devisable by 6, is: 54

Expert Answer

 

I have modified the code with a new code.

.file   1 ""
        .section .mdebug.abi32
        .previous
        .nan    legacy
        .module fp=32
        .module nooddspreg
        .abicalls
        .rdata
        .align  2
$LC0:
        .ascii  "How many positive number that is devisable by you want t"
        .ascii  "o add? 00"
        .align  2
$LC1:
        .ascii  "%d00"
        .align  2
$LC2:
        .ascii  "Enter a number: 00"
        .align  2
$LC3:
        .ascii  "%d1200"
        .align  2
$LC4:
        .ascii  "****ERROR: %d is not a positive number.Enter another num"
        .ascii  "ber00"
        .align  2
$LC5:
        .ascii  "****ERROR: %d is not in range of 1 to 100.Enter another "
        .ascii  "number00"
        .align  2
$LC6:
        .ascii  "Sum is %d00"
        .text
        .align  2
        .globl  main
        .set    nomips16
        .set    nomicromips
        .ent    main
        .type   main, @function
main:
        .frame  $fp,48,$31              # vars= 16, regs= 2/0, args= 16, gp= 8
        .mask   0xc0000000,-4
        .fmask  0x00000000,0
        .set    noreorder
        .cpload $25
        .set    nomacro
        addiu   $sp,$sp,-48
        sw      $31,44($sp)
        sw      $fp,40($sp)
        move    $fp,$sp
        .cprestore      16
        movz    $31,$31,$0
        sw      $0,28($fp)
        lw      $2,%got($LC0)($28)
        nop
        addiu   $4,$2,%lo($LC0)
        lw      $2,%call16(puts)($28)
        nop
        move    $25,$2
        .reloc  1f,R_MIPS_JALR,puts
1:      jalr    $25
        nop

        lw      $28,16($fp)
        addiu   $2,$fp,32
        move    $5,$2
        lw      $2,%got($LC1)($28)
        nop
        addiu   $4,$2,%lo($LC1)
        lw      $2,%call16(__isoc99_scanf)($28)
        nop
        move    $25,$2
        .reloc  1f,R_MIPS_JALR,__isoc99_scanf
1:      jalr    $25
        nop

        lw      $28,16($fp)
        sw      $0,24($fp)
        b       $L2
        nop

$L7:
        lw      $2,%got($LC2)($28)
        nop
        addiu   $4,$2,%lo($LC2)
        lw      $2,%call16(printf)($28)
        nop
        move    $25,$2
        .reloc  1f,R_MIPS_JALR,printf
1:      jalr    $25
        nop

        lw      $28,16($fp)
        addiu   $2,$fp,36
        move    $5,$2
        lw      $2,%got($LC3)($28)
        nop
        addiu   $4,$2,%lo($LC3)
        lw      $2,%call16(__isoc99_scanf)($28)
        nop
        move    $25,$2
        .reloc  1f,R_MIPS_JALR,__isoc99_scanf
1:      jalr    $25
        nop

        lw      $28,16($fp)
        lw      $2,36($fp)
        nop
        bgez    $2,$L3
        nop

        lw      $2,36($fp)
        nop
        move    $5,$2
        lw      $2,%got($LC4)($28)
        nop
        addiu   $4,$2,%lo($LC4)
        lw      $2,%call16(printf)($28)
        nop
        move    $25,$2
        .reloc  1f,R_MIPS_JALR,printf
1:      jalr    $25
        nop

        lw      $28,16($fp)
$L3:
        lw      $2,36($fp)
        nop
        beq     $2,$0,$L4
        nop

        lw      $2,36($fp)
        nop
        slt     $2,$2,101
        bne     $2,$0,$L5
        nop

$L4:
        lw      $2,36($fp)
        nop
        move    $5,$2
        lw      $2,%got($LC5)($28)
        nop
        addiu   $4,$2,%lo($LC5)
        lw      $2,%call16(printf)($28)
        nop
        move    $25,$2
        .reloc  1f,R_MIPS_JALR,printf
1:      jalr    $25
        nop

        lw      $28,16($fp)
$L5:
        lw      $2,36($fp)
        nop
        bgtz    $2,$L6
        nop

        lw      $2,36($fp)
        nop
        slt     $2,$2,101
        beq     $2,$0,$L7
        nop

$L6:
        lw      $3,36($fp)
        li      $2,6                    # 0x6
        bne     $2,$0,1f
        div     $0,$3,$2
        break   7
1:
        mfhi    $2
        bne     $2,$0,$L8
        nop

        lw      $2,36($fp)
        lw      $3,28($fp)
        nop
        addu    $2,$3,$2
        sw      $2,28($fp)
$L8:
        lw      $2,24($fp)
        nop
        addiu   $2,$2,1
        sw      $2,24($fp)
$L2:
        lw      $2,32($fp)
        lw      $3,24($fp)
        nop
        slt     $2,$3,$2
        bne     $2,$0,$L7
        nop

        lw      $5,28($fp)
        lw      $2,%got($LC6)($28)
        nop
        addiu   $4,$2,%lo($LC6)
        lw      $2,%call16(printf)($28)
        nop
        move    $25,$2
        .reloc  1f,R_MIPS_JALR,printf
1:      jalr    $25
        nop

        lw      $28,16($fp)
        move    $2,$0
        move    $sp,$fp
        lw      $31,44($sp)
        lw      $fp,40($sp)
        addiu   $sp,$sp,48
        j       $31
        nop

        .set    macro
        .set    reorder
        .end    main
        .size   main, .-main
        .ident  "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609"
Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.

× How can I help you?