Write a SPIM assembly language program numvowels based on th

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:

Prompt the user to enter a string.

The program will call the procedure vowelp to check if a character entered in the string is a vowel or not.

Count how many vowels and how many non-vowels are in the string.

Print out the calculated results with appropriate message.

Hint: A loop is needed.

Solution

Answer:

Assembly Language Code :

.zero 1
.LC0:
.string \"Enter a line of string:\ \"
.LC1:
.string \"Vowels: \"
.LC2:
.string \"\ Consonants: \"
.LC3:
.string \"\ Digits: \"
.LC4:
.string \"\ White spaces: \"
main:
push rbp
mov rbp, rsp
sub rsp, 192
mov DWORD PTR [rbp-20], 0
mov eax, DWORD PTR [rbp-20]
mov DWORD PTR [rbp-16], eax
mov eax, DWORD PTR [rbp-16]
mov DWORD PTR [rbp-24], eax
mov eax, DWORD PTR [rbp-24]
mov DWORD PTR [rbp-12], eax
mov eax, DWORD PTR [rbp-12]
mov DWORD PTR [rbp-8], eax
mov eax, DWORD PTR [rbp-8]
mov DWORD PTR [rbp-28], eax
mov esi, OFFSET FLAT:.LC0
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
lea rax, [rbp-192]
mov rdi, rax
call gets
mov DWORD PTR [rbp-4], 0
.L10:
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
test al, al
je .L2
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
cmp al, 97
je .L3
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
cmp al, 101
je .L3
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
cmp al, 105
je .L3
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
cmp al, 111
je .L3
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
cmp al, 117
je .L3
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
cmp al, 65
je .L3
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
cmp al, 69
je .L3
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
cmp al, 73
je .L3
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
cmp al, 79
je .L3
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
cmp al, 85
jne .L4
.L3:
add DWORD PTR [rbp-8], 1
jmp .L5
.L4:
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
cmp al, 96
jle .L6
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
cmp al, 122
jle .L7
.L6:
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
cmp al, 64
jle .L8
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
cmp al, 90
jg .L8
.L7:
add DWORD PTR [rbp-12], 1
jmp .L5
.L8:
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
cmp al, 47
jle .L9
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
cmp al, 57
jg .L9
add DWORD PTR [rbp-16], 1
jmp .L5
.L9:
mov eax, DWORD PTR [rbp-4]
cdqe
movzx eax, BYTE PTR [rbp-192+rax]
cmp al, 32
jne .L5
add DWORD PTR [rbp-20], 1
.L5:
add DWORD PTR [rbp-4], 1
jmp .L10
.L2:
mov esi, OFFSET FLAT:.LC1
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
mov rdx, rax
mov eax, DWORD PTR [rbp-8]
mov esi, eax
mov rdi, rdx
call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
mov esi, OFFSET FLAT:.LC2
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
mov rdx, rax
mov eax, DWORD PTR [rbp-12]
mov esi, eax
mov rdi, rdx
call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
mov esi, OFFSET FLAT:.LC3
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
mov rdx, rax
mov eax, DWORD PTR [rbp-16]
mov esi, eax
mov rdi, rdx
call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
mov esi, OFFSET FLAT:.LC4
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
mov rdx, rax
mov eax, DWORD PTR [rbp-20]
mov esi, eax
mov rdi, rdx
call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
mov eax, 0
leave
ret
__static_initialization_and_destruction_0(int, int):
push rbp
mov rbp, rsp
sub rsp, 16
mov DWORD PTR [rbp-4], edi
mov DWORD PTR [rbp-8], esi
cmp DWORD PTR [rbp-4], 1
jne .L14
cmp DWORD PTR [rbp-8], 65535
jne .L14
mov edi, OFFSET FLAT:std::__ioinit
call std::ios_base::Init::Init()
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:std::__ioinit
mov edi, OFFSET FLAT:std::ios_base::Init::~Init()
call __cxa_atexit
.L14:
nop
leave
ret
push rbp
mov rbp, rsp
mov esi, 65535
mov edi, 1
call __static_initialization_and_destruction_0(int, int)
pop rbp
ret

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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site