Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a MIPS assembly code using branch and syscall instructions: Also, here are

ID: 3869972 • Letter: W

Question

Write a MIPS assembly code using branch and syscall instructions:

Also, here are the sample outputs:

Assignment Description: Write a MIPS assembly language program that reads a customer's current and previous meter readings of electricity and a month to compute its electricity bill. If a customer spent 0 or less (technically this should not happen, though) KWH (kilowatt-hours) that is computed by current meter reading previous meter reading, then the program should print out "There is no bill to pay.ln". If a customer spent less than or equals to 300 KWH in a month, then the payment should be 20 dollars If a customer spent more than 300 KWH in a month of May, June, July, August, or September, then the payment is computed by: payment-20 + (used KWH - 300)/15; If a customer spent more than 300 KWH in any other month, then the payment is compute payment 20 int currentleter + (use KWH- 300) /20 int usedKH; int month; int payment; printf("Please enter the current electricity meter reading: "); Then ifthe //read an integer from a user input and store it in currentMeter scanf("%d" , &currentMeter; printf("Please enter the previous electricity meter reading: In"); greater than //read an integer from a user input and store it in previousMeter scanf("%d", &previou; sMeter); print out the paymen amount, along with its used KWH. printf("Please enter a month to compute their electricity bill, "; printf("Use an integer between 1 and 12 (1 for January, etc.): "); //read an integer from a user input and store it in month scant("%d", &month;); usedKNH = currentleter previousMeter; - The following shows howit c looks like in a C program printf("There is no bi1l to pay. "); else //compute its bill if (usedKWH 300 && month >. 5 && month 9) payment 20 (usedKMH-300)/15; = + else payment 20 (usedKNH-300)/20; + //print out the payment printf("Your total payment for this month: %d dollar(s) for %d Hiin", payment, usedKAH) ; //end of else

Explanation / Answer


.file 1 "" .section .mdebug.abi32 .previous .nan legacy .module fp=32 .module nooddspreg .abicalls .rdata .align 2 $LC0: .ascii "Please enter the current electricity meter reading:" .align 2 $LC1: .ascii "%d" .align 2 $LC2: .ascii "Please enter the previous electricity meter reading:" .align 2 $LC3: .ascii "Please enter a month to compute their electricity bill," .align 2 $LC4: .ascii "Use an integer between 1 and 12 (1 for January, etc.):" .align 2 $LC5: .ascii "There is no bill to pay." .align 2 $LC6: .ascii "Your total payment for this month: %d dollar(s) for %d K" .ascii "WH " .text .align 2 .globl main .set nomips16 .set nomicromips .ent main .type main, @function main: .frame $fp,56,$31 # vars= 24, regs= 2/0, args= 16, gp= 8 .mask 0xc0000000,-4 .fmask 0x00000000,0 .set noreorder .cpload $25 .set nomacro addiu $sp,$sp,-56 sw $31,52($sp) sw $fp,48($sp) move $fp,$sp .cprestore 16 movz $31,$31,$0 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) nop lw $2,%got($LC2)($28) nop addiu $4,$2,%lo($LC2) 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,36 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) nop lw $2,%got($LC3)($28) nop addiu $4,$2,%lo($LC3) lw $2,%call16(puts)($28) nop move $25,$2 .reloc 1f,R_MIPS_JALR,puts 1: jalr $25 nop lw $28,16($fp) nop lw $2,%got($LC4)($28) nop addiu $4,$2,%lo($LC4) 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,40 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) lw $3,32($fp) lw $2,36($fp) nop subu $2,$3,$2 sw $2,28($fp) lw $2,28($fp) nop bgtz $2,$L2 nop lw $2,%got($LC5)($28) nop addiu $4,$2,%lo($LC5) lw $2,%call16(puts)($28) nop move $25,$2 .reloc 1f,R_MIPS_JALR,puts 1: jalr $25 nop lw $28,16($fp) b $L3 nop $L2: lw $2,28($fp) nop slt $2,$2,301 beq $2,$0,$L4 nop li $2,20 # 0x14 sw $2,24($fp) b $L5 nop $L4: lw $2,28($fp) nop slt $2,$2,301 bne $2,$0,$L6 nop lw $2,40($fp) nop slt $2,$2,5 bne $2,$0,$L6 nop lw $2,40($fp) nop slt $2,$2,10 beq $2,$0,$L6 nop lw $2,28($fp) nop addiu $3,$2,-300 li $2,15 # 0xf bne $2,$0,1f div $0,$3,$2 break 7 1: mfhi $2 mflo $2 addiu $2,$2,20 sw $2,24($fp) b $L5 nop $L6: lw $2,28($fp) nop addiu $3,$2,-300 li $2,20 # 0x14 bne $2,$0,1f div $0,$3,$2 break 7 1: mfhi $2 mflo $2 addiu $2,$2,20 sw $2,24($fp) $L5: lw $6,28($fp) lw $5,24($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) $L3: move $2,$0 move $sp,$fp lw $31,52($sp) lw $fp,48($sp) addiu $sp,$sp,56 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"

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote