Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Mips assembly language. I'm trying to read from a file and count how many lines there are in the file based on the next line

Mips assembly language. I'm trying to read from a file and count how many lines there are in the file based on the next line characters. Here is my MIPS code:

.data

testOutput: .word 0

fin: .asciiz "data.txt"

.align 2

fout: .asciiz "Billing.txt"

buffer: .space 20

line: .space 50

.text

#open input file

li $v0, 13

la $a0, fin

li $a1, 0

li $a2, 0

syscall

move $s6, $v0

#read from file

li $v0, 14

move $a0, $s6

la $a1, buffer

li $a2, 14

syscall

la $s0, buffer

addi $s2, $s0, 0

addi $s3, $s0, 0

jal loop

sw $v0, testOutput

#print output

li $v0,1

move $a0,$v0

syscall

li $v0, 10

syscall

loop:

la $s1, 0($0)

bnez $s1, exit

addi $s0, $s0, 1

addi $s2, $s2, 1

beq $s1, ' ', update

update:

addi $v0, $s3, 1

jr $ra

j loop

exit:

li $v0, 10

syscall

The sample for data.txt as follow:

B12345 16 04 R44212 00 03 B22314 12 05 R23341 00 02 B84772 08 01 B74682 05 02 R87864 00 04 R74621 00 11 B33123 10 07 B53622 07 04 R49124 00 08 B78747 15 05 R67232 00 14 R23427 00 04 B37834 07 12

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions

Question

Did the team members feel that their work mattered

Answered: 1 week ago

Question

3. What may be the goal of the team?

Answered: 1 week ago