Question

Programming: Write a SPIM assembly language program num-vowel.s based on the hardware implementation method in the...

Programming:

Write a SPIM assembly language program num-vowel.s based on the hardware implementation method in the lab notes and the above practice.
The program will do the following:

  1. Prompt the user to enter a string.
  2. The program will call the procedure vowelp to check if a character entered in the string is a vowel or not.
  3. Count how many vowels and how many non-vowels are in the string.
  4. Print out the calculated results with appropriate message.
  5. Hint: A loop is needed.

You will run this program in the hardware and
show your testing result with input "Hello There!"

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE:

$LC0:

.ascii "Vowels: \000"

$LC1:

.ascii "Non Vowels: \000"

fun(char*):

addiu $sp,$sp,-48

sw $31,44($sp)

sw $fp,40($sp)

move $fp,$sp

sw $4,48($fp)

sw $0,28($fp)

lw $2,28($fp)

nop

sw $2,24($fp)

sw $0,32($fp)

$L8:

lw $2,32($fp)

lw $3,48($fp)

nop

addu $2,$3,$2

lb $2,0($2)

nop

beq $2,$0,$L2

nop

lw $2,32($fp)

lw $3,48($fp)

nop

addu $2,$3,$2

lb $3,0($2)

li $2,97 # 0x61

beq $3,$2,$L3

nop

lw $2,32($fp)

lw $3,48($fp)

nop

addu $2,$3,$2

lb $3,0($2)

li $2,101 # 0x65

beq $3,$2,$L3

nop

lw $2,32($fp)

lw $3,48($fp)

nop

addu $2,$3,$2

lb $3,0($2)

li $2,105 # 0x69

beq $3,$2,$L3

nop

lw $2,32($fp)

lw $3,48($fp)

nop

addu $2,$3,$2

lb $3,0($2)

li $2,111 # 0x6f

beq $3,$2,$L3

nop

lw $2,32($fp)

lw $3,48($fp)

nop

addu $2,$3,$2

lb $3,0($2)

li $2,117 # 0x75

beq $3,$2,$L3

nop

lw $2,32($fp)

lw $3,48($fp)

nop

addu $2,$3,$2

lb $3,0($2)

li $2,65 # 0x41

beq $3,$2,$L3

nop

lw $2,32($fp)

lw $3,48($fp)

nop

addu $2,$3,$2

lb $3,0($2)

li $2,69 # 0x45

beq $3,$2,$L3

nop

lw $2,32($fp)

lw $3,48($fp)

nop

addu $2,$3,$2

lb $3,0($2)

li $2,73 # 0x49

beq $3,$2,$L3

nop

lw $2,32($fp)

lw $3,48($fp)

nop

addu $2,$3,$2

lb $3,0($2)

li $2,79 # 0x4f

beq $3,$2,$L3

nop

lw $2,32($fp)

lw $3,48($fp)

nop

addu $2,$3,$2

lb $3,0($2)

li $2,85 # 0x55

bne $3,$2,$L4

nop

$L3:

lw $2,24($fp)

nop

addiu $2,$2,1

sw $2,24($fp)

b $L5

nop

$L4:

lw $2,32($fp)

lw $3,48($fp)

nop

addu $2,$3,$2

lb $2,0($2)

nop

slt $2,$2,97

bne $2,$0,$L6

nop

lw $2,32($fp)

lw $3,48($fp)

nop

addu $2,$3,$2

lb $2,0($2)

nop

slt $2,$2,123

bne $2,$0,$L7

nop

$L6:

lw $2,32($fp)

lw $3,48($fp)

nop

addu $2,$3,$2

lb $2,0($2)

nop

slt $2,$2,65

bne $2,$0,$L5

nop

lw $2,32($fp)

lw $3,48($fp)

nop

addu $2,$3,$2

lb $2,0($2)

nop

slt $2,$2,91

beq $2,$0,$L5

nop

$L7:

lw $2,28($fp)

nop

addiu $2,$2,1

sw $2,28($fp)

$L5:

lw $2,32($fp)

nop

addiu $2,$2,1

sw $2,32($fp)

b $L8

nop

$L2:

lui $2,%hi($LC0)

addiu $5,$2,%lo($LC0)

lui $2,%hi(_ZSt4cout)

addiu $4,$2,%lo(_ZSt4cout)

jal std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)

nop

lw $5,24($fp)

move $4,$2

jal std::basic_ostream<char, std::char_traits<char> >::operator<<(int)

nop

move $3,$2

lui $2,%hi(_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)

addiu $5,$2,%lo(_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)

move $4,$3

jal std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))

nop

lui $2,%hi($LC1)

addiu $5,$2,%lo($LC1)

lui $2,%hi(_ZSt4cout)

addiu $4,$2,%lo(_ZSt4cout)

jal std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)

nop

lw $5,28($fp)

move $4,$2

jal std::basic_ostream<char, std::char_traits<char> >::operator<<(int)

nop

move $3,$2

lui $2,%hi(_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)

addiu $5,$2,%lo(_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)

move $4,$3

jal std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))

nop

nop

move $sp,$fp

lw $31,44($sp)

lw $fp,40($sp)

addiu $sp,$sp,48

j $31

nop

$LC2:

.ascii "Enter a line of string: \000"

main:

addiu $sp,$sp,-184

sw $31,180($sp)

sw $fp,176($sp)

move $fp,$sp

lui $2,%hi($LC2)

addiu $5,$2,%lo($LC2)

lui $2,%hi(_ZSt4cout)

addiu $4,$2,%lo(_ZSt4cout)

jal std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)

nop

li $6,150 # 0x96

addiu $2,$fp,24

move $5,$2

lui $2,%hi(_ZSt3cin)

addiu $4,$2,%lo(_ZSt3cin)

jal std::basic_istream<char, std::char_traits<char> >::getline(char*, int)

nop

addiu $2,$fp,24

move $4,$2

jal fun(char*)

nop

move $2,$0

move $sp,$fp

lw $31,180($sp)

lw $fp,176($sp)

addiu $sp,$sp,184

j $31

nop

__static_initialization_and_destruction_0(int, int):

addiu $sp,$sp,-32

sw $31,28($sp)

sw $fp,24($sp)

move $fp,$sp

sw $4,32($fp)

sw $5,36($fp)

lw $3,32($fp)

li $2,1 # 0x1

bne $3,$2,$L13

nop

lw $3,36($fp)

li $2,65535 # 0xffff

bne $3,$2,$L13

nop

lui $2,%hi(_ZStL8__ioinit)

addiu $4,$2,%lo(_ZStL8__ioinit)

jal std::ios_base::Init::Init() [complete object constructor]

nop

lui $2,%hi(__dso_handle)

addiu $6,$2,%lo(__dso_handle)

lui $2,%hi(_ZStL8__ioinit)

addiu $5,$2,%lo(_ZStL8__ioinit)

lui $2,%hi(_ZNSt8ios_base4InitD1Ev)

addiu $4,$2,%lo(_ZNSt8ios_base4InitD1Ev)

jal __cxa_atexit

nop

$L13:

nop

move $sp,$fp

lw $31,28($sp)

lw $fp,24($sp)

addiu $sp,$sp,32

j $31

nop

_GLOBAL__sub_I_fun(char*):

addiu $sp,$sp,-32

sw $31,28($sp)

sw $fp,24($sp)

move $fp,$sp

li $5,65535 # 0xffff

li $4,1 # 0x1

jal __static_initialization_and_destruction_0(int, int)

nop

move $sp,$fp

lw $31,28($sp)

lw $fp,24($sp)

addiu $sp,$sp,32

j $31

nop

SCREENSHOT:

Enter a line of string: Hello there! Vowels: 4 Non Vowels: 6

Add a comment
Know the answer?
Add Answer to:
Programming: Write a SPIM assembly language program num-vowel.s based on the hardware implementation method in 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
  • // Write a program that determines how many of each type of vowel are in an...

    // Write a program that determines how many of each type of vowel are in an entered string of 50 characters or less. // The program should prompt the user for a string. // The program should then sequence through the string character by character (till it gets to the NULL character) and count how many of each type of vowel are in the string. // Vowels: a, e, i, o, u. // Output the entered string, how many of...

  • 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...

  • Write a basic ARM program that takes a string as input, then outputs a string that...

    Write a basic ARM program that takes a string as input, then outputs a string that replaces all the vowels in the input string with 'x'. Vowels: a, A, e, E, i, I, o, O, u, U. **I am using DS-5 Eclipse Community Workspace with ARM assembly language.** The program should give the following input prompt: "Input a string: " Then, the program should output the string with the vowel(s) replaced with x. The program should terminate upon printing the...

  • ‘C’ programming language question Write a MENU DRIVEN program to A) Count the number of vowels...

    ‘C’ programming language question Write a MENU DRIVEN program to A) Count the number of vowels in the string B) Count the number of consonants in the string C) Convert the string to uppercase D) Convert the string to lowercase E) Display the current string X) Exit the program The program should start with a user prompt to enter a string, and let them type it in. Then the menu would be displayed. User may enter option in small case...

  • 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 C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one...

    In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.

  • In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one...

    In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.

  • [ASSEMBLY LANGUAGE] Write a program that prompt a message to one letter from the user's input...

    [ASSEMBLY LANGUAGE] Write a program that prompt a message to one letter from the user's input and displays this single character in all possible combinations of foreground and background colors (16 x16 = 256). The colors are numbered from 0 to 15, so you can use a nested loop to generate all possible combinations.

  • Write a program that will allow the user to specify how many times the program will...

    Write a program that will allow the user to specify how many times the program will loop and display the title of the program include your name in the title, print from in the loop a string and count. -Assembly Language MASM 8086

  • Assembly Language////Write a program that read in 10 integers from the user. Save the numbers into...

    Assembly Language////Write a program that read in 10 integers from the user. Save the numbers into an array; reverse the array and display the reversed array. .data arrayInt DWORD 10 DUP(?) Your program consists of 4 procedures: 1. main procedure: call procedures getInput, reverseArray, displayArray 2. getInput procedure: prompt user to enter 10 integer numbers, save the numbers into the memory for the arrayInt 3. reverseArray: reverse arrayInt 4. displayArray: display the reversed array

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
ADVERTISEMENT