Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can anyone help finishing the mips, I am not sure how to finish it ?? # Purpose: Practice rotate & AND to remove spare blanks

Can anyone help finishing the mips, I am not sure how to finish it ?? # Purpose: Practice rotate & AND to remove spare blanks # Write a MIPS assembler program to remove the extra blanks from # a string: # INPUT: "Two bee ore knot too Bea that" # PATTERN:00011000100011000010001100010000 # ROTATE: 00110001000110000100011000100000 # AND: 00010000000010000000001000000000 # RESULT:"Two bee ore knot too Bea that " .data .eqv SYS_PRINT_WORD 1 #word, byte, character .eqv SYS_PRINT_FLOAT 2 #float .eqv SYS_PRINT_DOUBLE 3 #double .eqv SYS_PRINT_TEXT 4 #text (zero terminated) .eqv SYS_INPUT_WORD 5 #input word .eqv SYS_INPUT_FLOAT 6 #input float .eqv SYS_PRINT_BIN 35 #print binary .eqv SYS_EXIT 10 #terminate # declare variables .eqv BLANK 32 #12345678901234567890123456789012 text: .ascii "Two bee ore knot too Bea that" end_text: .asciiz " " result: .ascii " " end_result: .asciiz " " blank: .byte ' ' endl: .asciiz " " endl2: .asciiz " " .text .globl main main: # Print starting text la $a0, text li $v0, SYS_PRINT_TEXT syscall # ---------------------------------------------------------------- # Create the bit pattern with a 1 where each blanks exists # ---------------------------------------------------------------- la $s7, end_text # s7 = ending address for loop la $s1, text # s1 = text address move $s0, $zero # s0 = the bit pattern loop1: sll $s0,$s0,1 # shift pattern left lbu $t2, 0($s1) # get 'text' byte li $t1, BLANK bne $t1, $t2, noBlank # compare with BLANK # set s0 bit0 for BLANK, else skip to noBlank, not setting bit0 ori $s0, $s0, 1 noBlank: addiu $s1, $s1, 1 # move to next character bne $s1, $s7, loop1 # loop1 if not done (s1 != s7) move $a0, $s0 # print s0 pattern li $v0, SYS_PRINT_BIN syscall la $a0, endl li $v0, SYS_PRINT_TEXT syscall # ---------------------------------------------------------------- # Duplicate bit pattern, Rotate left, AND the two patterns # should be where extra blanks exist # ---------------------------------------------------------------- # print the AND pattern # ---------------------------------------------------------------- # Copy 'text' into 'result' for each zero bit in s3 pattern # ---------------------------------------------------------------- # ending s7 'end_text' address # source address 'text' in s0 # destination address 'result' in s1 loop2: # rotate high bit to bit0 # test bit0 # skip if bit0 is 1 # get character at (s0) # save character in (s1) # advance s1 'result' address skip: # advance s0 'text' address # loop2 if not done (s0 != s7) # print 'result' #---- terminate --- exit: li $v0, SYS_EXIT syscall #.end main

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

Deductive And Object Oriented Databases Second International Conference Dood 91 Munich Germany December 18 1991 Proceedings Lncs 566

Authors: Claude Delobel ,Michael Kifer ,Yoshifumi Masunaga

1st Edition

3540550151, 978-3540550150

More Books

Students also viewed these Databases questions