Write a SPIM assembly language program numvowels based on th

Write a SPIM assembly language program num-vowel.s based on the example program Is-vowel.s in the lab notes.
The program will do the following:

Prompt the user to enter a null terminated 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 other characters 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 an alphabet : \"
.LC1:
.string \"This is a vowel\"
.LC2:
.string \"This is not a vowel\"
main:
push rbp
mov rbp, rsp
sub rsp, 16
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-1]
mov rsi, rax
mov edi, OFFSET FLAT:std::cin
call std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char> >(std::basic_istream<char, std::char_traits<char> >&, char&)
movzx eax, BYTE PTR [rbp-1]
cmp al, 97
je .L2
movzx eax, BYTE PTR [rbp-1]
cmp al, 65
je .L2
movzx eax, BYTE PTR [rbp-1]
cmp al, 101
je .L2
movzx eax, BYTE PTR [rbp-1]
cmp al, 69
je .L2
movzx eax, BYTE PTR [rbp-1]
cmp al, 105
je .L2
movzx eax, BYTE PTR [rbp-1]
cmp al, 73
je .L2
movzx eax, BYTE PTR [rbp-1]
cmp al, 111
je .L2
movzx eax, BYTE PTR [rbp-1]
cmp al, 79
je .L2
movzx eax, BYTE PTR [rbp-1]
cmp al, 117
je .L2
movzx eax, BYTE PTR [rbp-1]
cmp al, 85
jne .L3
.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*)
jmp .L4
.L3:
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*)
.L4:
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 .L8
cmp DWORD PTR [rbp-8], 65535
jne .L8
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
.L8:
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 example program Is-vowel.s in the lab notes. The program will do the following: Prompt the user
Write a SPIM assembly language program num-vowel.s based on the example program Is-vowel.s in the lab notes. The program will do the following: Prompt the user

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site