Question

How do I write a program in MIPs assembly that will take 2 words from the...

How do I write a program in MIPs assembly that will take 2 words from the user and check if they're in a string. For example:

String: " A B Cat C Dog D E Cat cAT Owl Ferret"

User input:

Word 1: Owl

Word 2: Cat

OUTPUT:

Owl- 1 time(s)

Cat: 3 time(s)

Owl- #

Cat-###

0 0
Add a comment Improve this question Transcribed image text
Answer #1
.file     1 ""    .section .mdebug.abi32  .previous       .nan    legacy  .module fp=32   .module nooddspreg      .abicalls       .rdata  .align  2 $LC1:         .ascii  "word1:\000"    .align  2 $LC2:         .ascii  "word2:\000"    .align  2 $LC3:         .ascii  "\012%s - %d times\000"         .align  2 $LC4:         .ascii  "\012%s -\000"  .align  2 $LC0:         .ascii  "ABCatCDogDECatcATOwlFerret\000"        .text   .align  2       .globl  main    .set    nomips16        .set    nomicromips     .ent    main    .type   main, @function main:   .frame  $fp,136,$31             # vars= 96, regs= 3/0, args= 16, gp= 8  .mask   0xc0010000,-4   .fmask  0x00000000,0    .set    noreorder       .cpload $25     .set    nomacro         addiu   $sp,$sp,-136    sw      $31,132($sp)    sw      $fp,128($sp)    sw      $16,124($sp)    move    $fp,$sp         movz    $31,$31,$0      .cprestore      16      lw      $2,%got($LC0)($28)      nop     lw      $8,%lo($LC0)($2)        addiu   $3,$2,%lo($LC0)         lw      $7,4($3)        addiu   $3,$2,%lo($LC0)         lw      $6,8($3)        addiu   $3,$2,%lo($LC0)         lw      $5,12($3)       addiu   $3,$2,%lo($LC0)         lw      $4,16($3)       addiu   $3,$2,%lo($LC0)         lw      $3,20($3)       sw      $8,52($fp)      sw      $7,56($fp)      sw      $6,60($fp)      sw      $5,64($fp)      sw      $4,68($fp)      sw      $3,72($fp)      addiu   $2,$2,%lo($LC0)         lhu     $3,24($2)       nop     sh      $3,76($fp)      lbu     $2,26($2)       nop     sb      $2,78($fp)      sw      $0,24($fp)      sw      $0,28($fp)      lw      $2,%got($LC1)($28)      nop     addiu   $4,$2,%lo($LC1)         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,80       move    $4,$2   lw      $2,%call16(gets)($28)   nop     move    $25,$2  .reloc  1f,R_MIPS_JALR,gets 1:  jalr    $25     nop     lw      $28,16($fp)     nop     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,100      move    $4,$2   lw      $2,%call16(gets)($28)   nop     move    $25,$2  .reloc  1f,R_MIPS_JALR,gets 1:  jalr    $25     nop     lw      $28,16($fp)     sw      $0,32($fp)      b       $L2     nop $L15:       lb      $2,80($fp)      nop     move    $4,$2   lw      $2,%call16(toupper)($28)        nop     move    $25,$2  .reloc  1f,R_MIPS_JALR,toupper 1:       jalr    $25     nop     lw      $28,16($fp)     move    $16,$2  lw      $2,32($fp)      addiu   $3,$fp,24       addu    $2,$3,$2        lb      $2,28($2)       nop     move    $4,$2   lw      $2,%call16(toupper)($28)        nop     move    $25,$2  .reloc  1f,R_MIPS_JALR,toupper 1:       jalr    $25     nop     lw      $28,16($fp)     bne     $16,$2,$L3      nop     li      $2,1                    # 0x1   sw      $2,44($fp)      li      $2,1                    # 0x1   sw      $2,36($fp)      lw      $2,32($fp)      nop     addiu   $2,$2,1         sw      $2,40($fp)      b       $L4     nop $L8:        lw      $2,36($fp)      addiu   $3,$fp,24       addu    $2,$3,$2        lb      $2,56($2)       nop     move    $4,$2   lw      $2,%call16(toupper)($28)        nop     move    $25,$2  .reloc  1f,R_MIPS_JALR,toupper 1:       jalr    $25     nop     lw      $28,16($fp)     move    $16,$2  lw      $2,40($fp)      addiu   $3,$fp,24       addu    $2,$3,$2        lb      $2,28($2)       nop     move    $4,$2   lw      $2,%call16(toupper)($28)        nop     move    $25,$2  .reloc  1f,R_MIPS_JALR,toupper 1:       jalr    $25     nop     lw      $28,16($fp)     bne     $16,$2,$L21     nop     lw      $2,44($fp)      nop     addiu   $2,$2,1         sw      $2,44($fp)      lw      $2,36($fp)      nop     addiu   $2,$2,1         sw      $2,36($fp)      lw      $2,40($fp)      nop     addiu   $2,$2,1         sw      $2,40($fp) $L4:         addiu   $2,$fp,80       move    $4,$2   lw      $2,%call16(strlen)($28)         nop     move    $25,$2  .reloc  1f,R_MIPS_JALR,strlen 1:        jalr    $25     nop     lw      $28,16($fp)     move    $3,$2   lw      $2,36($fp)      nop     sltu    $2,$2,$3        bne     $2,$0,$L8       nop     b       $L7     nop $L21:       nop $L7:        addiu   $2,$fp,80       move    $4,$2   lw      $2,%call16(strlen)($28)         nop     move    $25,$2  .reloc  1f,R_MIPS_JALR,strlen 1:        jalr    $25     nop     lw      $28,16($fp)     move    $3,$2   lw      $2,44($fp)      nop     bne     $3,$2,$L3       nop     lw      $2,24($fp)      nop     addiu   $2,$2,1         sw      $2,24($fp) $L3:         lb      $2,100($fp)     nop     move    $4,$2   lw      $2,%call16(toupper)($28)        nop     move    $25,$2  .reloc  1f,R_MIPS_JALR,toupper 1:       jalr    $25     nop     lw      $28,16($fp)     move    $16,$2  lw      $2,32($fp)      addiu   $3,$fp,24       addu    $2,$3,$2        lb      $2,28($2)       nop     move    $4,$2   lw      $2,%call16(toupper)($28)        nop     move    $25,$2  .reloc  1f,R_MIPS_JALR,toupper 1:       jalr    $25     nop     lw      $28,16($fp)     bne     $16,$2,$L9      nop     li      $2,1                    # 0x1   sw      $2,48($fp)      li      $2,1                    # 0x1   sw      $2,36($fp)      lw      $2,32($fp)      nop     addiu   $2,$2,1         sw      $2,40($fp)      b       $L10    nop $L14:       lw      $2,36($fp)      addiu   $3,$fp,24       addu    $2,$3,$2        lb      $2,76($2)       nop     move    $4,$2   lw      $2,%call16(toupper)($28)        nop     move    $25,$2  .reloc  1f,R_MIPS_JALR,toupper 1:       jalr    $25     nop     lw      $28,16($fp)     move    $16,$2  lw      $2,40($fp)      addiu   $3,$fp,24       addu    $2,$3,$2        lb      $2,28($2)       nop     move    $4,$2   lw      $2,%call16(toupper)($28)        nop     move    $25,$2  .reloc  1f,R_MIPS_JALR,toupper 1:       jalr    $25     nop     lw      $28,16($fp)     bne     $16,$2,$L22     nop     lw      $2,48($fp)      nop     addiu   $2,$2,1         sw      $2,48($fp)      lw      $2,36($fp)      nop     addiu   $2,$2,1         sw      $2,36($fp)      lw      $2,40($fp)      nop     addiu   $2,$2,1         sw      $2,40($fp) $L10:        addiu   $2,$fp,100      move    $4,$2   lw      $2,%call16(strlen)($28)         nop     move    $25,$2  .reloc  1f,R_MIPS_JALR,strlen 1:        jalr    $25     nop     lw      $28,16($fp)     move    $3,$2   lw      $2,36($fp)      nop     sltu    $2,$2,$3        bne     $2,$0,$L14      nop     b       $L13    nop $L22:       nop $L13:       addiu   $2,$fp,100      move    $4,$2   lw      $2,%call16(strlen)($28)         nop     move    $25,$2  .reloc  1f,R_MIPS_JALR,strlen 1:        jalr    $25     nop     lw      $28,16($fp)     move    $3,$2   lw      $2,48($fp)      nop     bne     $3,$2,$L9       nop     lw      $2,28($fp)      nop     addiu   $2,$2,1         sw      $2,28($fp) $L9:         lw      $2,32($fp)      nop     addiu   $2,$2,1         sw      $2,32($fp) $L2:         addiu   $2,$fp,52       move    $4,$2   lw      $2,%call16(strlen)($28)         nop     move    $25,$2  .reloc  1f,R_MIPS_JALR,strlen 1:        jalr    $25     nop     lw      $28,16($fp)     move    $3,$2   lw      $2,32($fp)      nop     sltu    $2,$2,$3        bne     $2,$0,$L15      nop     addiu   $2,$fp,80       lw      $6,24($fp)      move    $5,$2   lw      $2,%got($LC3)($28)      nop     addiu   $4,$2,%lo($LC3)         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,100      lw      $6,28($fp)      move    $5,$2   lw      $2,%got($LC3)($28)      nop     addiu   $4,$2,%lo($LC3)         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,100      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)     b       $L16    nop $L17:       li      $4,35                   # 0x23  lw      $2,%call16(putchar)($28)        nop     move    $25,$2  .reloc  1f,R_MIPS_JALR,putchar 1:       jalr    $25     nop     lw      $28,16($fp) $L16:       lw      $2,28($fp)      nop     addiu   $3,$2,-1        sw      $3,28($fp)      bne     $2,$0,$L17      nop     addiu   $2,$fp,80       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)     b       $L18    nop $L19:       li      $4,35                   # 0x23  lw      $2,%call16(putchar)($28)        nop     move    $25,$2  .reloc  1f,R_MIPS_JALR,putchar 1:       jalr    $25     nop     lw      $28,16($fp) $L18:       lw      $2,24($fp)      nop     addiu   $3,$2,-1        sw      $3,24($fp)      bne     $2,$0,$L19      nop     move    $2,$0   move    $sp,$fp         lw      $31,132($sp)    lw      $fp,128($sp)    lw      $16,124($sp)    addiu   $sp,$sp,136     j       $31     nop     .set    macro   .set    reorder         .end    main    .size   main, .-main    .ident  "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609"
Add a comment
Know the answer?
Add Answer to:
How do I write a program in MIPs assembly that will take 2 words from the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • How do I write a C program that finds how many times a word is used...

    How do I write a C program that finds how many times a word is used in a string and prints the result. The string is hardcoded. How do I also make it print the hashes? For instance: String: " Dog Cat Owl Ferret Rabbit Cat Dolphin Penguin Cat" Word 1: Owl Word 2: Cat Desired Output: Owl- 1 time(s) Cat: 3 time(s) Owl- # Cat-###

  • 2. Searching a String: Write a MIPS assembly language program to do the following: Read a...

    2. Searching a String: Write a MIPS assembly language program to do the following: Read a string and store it in memory. Limit the string length to 100 characters. Then, ask the user to enter a character. Search and count the number of occurrences of the character in the string. The search is not case sensitive. Lowercase and uppercase letters should be equal. Then ask the user to enter a string of two characters. Search and count the number of...

  • I need my c++ code converted to MASM (assembly language). The instructions below: write an assembly...

    I need my c++ code converted to MASM (assembly language). The instructions below: write an assembly program that does the following; 1. count and display the number of words in the user input string. 2. Flip the case of each character from upper to lower or lower to upper. For example if the user types in:   "Hello thEre. How aRe yOu?" Your output should be: The number of words in the input string is: 5 The output string is : hELLO...

  • In this part of the assignment, you will write MIPS assembly code to replace characters in...

    In this part of the assignment, you will write MIPS assembly code to replace characters in a string. This program asks the user for a string named string and two characters orig and new. It then replaces each instance of the character orig found in string with the character new. It outputs the resulting string and the number of substitutions that were made. For example, if string were "wow", orig were 'w', and new were 'b', the program would output...

  • Write a MIPS Assembly program to accept two numbers A and B from the user. Print...

    Write a MIPS Assembly program to accept two numbers A and B from the user. Print all the prime numbers between A and B. Also, check if A and B are prime. If no prime number exits print the string "No prime number between numbers A and B"

  • Write a program in MIPs Assembly Language to compute nth number of a fibonacci number sequence....

    Write a program in MIPs Assembly Language to compute nth number of a fibonacci number sequence. Your program should prompt for an integer input n from the user. The program should call a recursive function to compute the nth fibonacci number. Your program must follow programming convention. You should submit program and screenshot of output in a single word/pdf file. You should use following recursive definition of fibonacci function: fib(0) = 0 fib(1) = 1 fib(n) = fib(n-1) +fib(n-2)

  • MIPS ASSEMBLY PROGRAM: PLEASE Write in MIPS Assembly language. Take strings as input and calculate and...

    MIPS ASSEMBLY PROGRAM: PLEASE Write in MIPS Assembly language. Take strings as input and calculate and print a simple checksum for each string. Make your string long enough to hold 50 characters. Don't forget to leave space for the null byte. Our checksum algorithm will produce a value which you can print with the syscall for printing a character. Stop reading strings when the user enters ".". The syscall to read a string (sycall code 8) adds a newline to...

  • MIPS Assembly Language * Write a simple program to count the number of non overlapping repetitions...

    MIPS Assembly Language * Write a simple program to count the number of non overlapping repetitions of a character pattern in a character string. For example " the pattern "aa" appears twice in the in the string "aabbaaa". Provide a user interface to read the character pattern and the string.

  • in Mips how do i get a input string from a user and then print it...

    in Mips how do i get a input string from a user and then print it to the screen? for example if a user enters A6B4GYJx how do i get that and then print it to the screen?

  • 7.13 LAB: Word frequencies (lists) Write a program that first reads in the name of an...

    7.13 LAB: Word frequencies (lists) Write a program that first reads in the name of an input file and then reads the file using the csv.reader() method. The file contains a list of words separated by commas. Your program should output the words and their frequencies (the number of times each word appears in the file) without any duplicates. Ex: If the input is: input1.csv and the contents of input1.csv are: hello,cat,man,hey,dog,boy,Hello,man,cat,woman,dog,Cat,hey,boy the output is: hello 1 cat 2 man...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT