Pep8 Assembly Question Write a Pep8 subroutine strlen It tak

Pep/8 Assembly Question

Write a Pep/8 subroutine strlen. It takes one parameter: a pointer to a null-terminated string (S) of characters. It returns as its result the number of ion-null characters in S.

Solution

Answer:

Assembly Language Code :

.zero 1

.LC1:
.string \"String Length = \"
main:
push rbp
mov rbp, rsp
push rbx
sub rsp, 56
lea rax, [rbp-17]
mov rdi, rax
call std::allocator<char>::allocator()
lea rdx, [rbp-17]
lea rax, [rbp-64]
mov esi, OFFSET FLAT:.LC0
mov rdi, rax
call std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)
lea rax, [rbp-17]
mov rdi, rax
call std::allocator<char>::~allocator()
lea rax, [rbp-64]
mov rdi, rax
call std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const
mov rbx, rax
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 rsi, rbx
mov rdi, rax
call std::basic_ostream<char, std::char_traits<char> >::operator<<(unsigned long)
mov ebx, 0
lea rax, [rbp-64]
mov rdi, rax
call std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()
mov eax, ebx
jmp .L7
mov rbx, rax
lea rax, [rbp-17]
mov rdi, rax
call std::allocator<char>::~allocator()
mov rax, rbx
mov rdi, rax
call _Unwind_Resume
mov rbx, rax
lea rax, [rbp-64]
mov rdi, rax
call std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()
mov rax, rbx
mov rdi, rax
call _Unwind_Resume
.L7:
add rsp, 56
pop rbx
pop rbp
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 .L10
cmp DWORD PTR [rbp-8], 65535
jne .L10
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
.L10:
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

Pep/8 Assembly Question Write a Pep/8 subroutine strlen. It takes one parameter: a pointer to a null-terminated string (S) of characters. It returns as its resu
Pep/8 Assembly Question Write a Pep/8 subroutine strlen. It takes one parameter: a pointer to a null-terminated string (S) of characters. It returns as its resu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site