Answer:
Assembly Language Code :
.zero 1
.LC0:
.string "Enter a string :"
.LC1:
.string "The number of uppercase letters are :"
.LC2:
.string "The number of lowercase letters are :"
.LC3:
.string "The total number of characters are : "
main:
pushq %rbp
movq %rsp, %rbp
subq $1024, %rsp
movl $0, -8(%rbp)
movl $0, -12(%rbp)
movl $0, -16(%rbp)
movl $.LC0, %esi
movl std::cout, %edi
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
leaq -1024(%rbp), %rax
movl $1000, %edx
movq %rax, %rsi
movl std::cin, %edi
call std::basic_istream >::getline(char*, long)
movl $0, -4(%rbp)
.L5:
movl -4(%rbp), %eax
cltq
movzbl -1024(%rbp,%rax), %eax
testb %al, %al
je .L2
movl -4(%rbp), %eax
cltq
movzbl -1024(%rbp,%rax), %eax
cmpb $64, %al
jle .L3
movl -4(%rbp), %eax
cltq
movzbl -1024(%rbp,%rax), %eax
cmpb $90, %al
jg .L3
addl $1, -12(%rbp)
.L3:
movl -4(%rbp), %eax
cltq
movzbl -1024(%rbp,%rax), %eax
cmpb $96, %al
jle .L4
movl -4(%rbp), %eax
cltq
movzbl -1024(%rbp,%rax), %eax
cmpb $122, %al
jg .L4
addl $1, -16(%rbp)
.L4:
addl $1, -4(%rbp)
jmp .L5
.L2:
movl $.LC1, %esi
movl std::cout, %edi
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
movq %rax, %rdx
movl -12(%rbp), %eax
movl %eax, %esi
movq %rdx, %rdi
call std::basic_ostream >::operator<<(int)
movl std::basic_ostream >& std::endl >(std::basic_ostream >&), %esi
movq %rax, %rdi
call std::basic_ostream >::operator<<(std::basic_ostream >& (*)(std::basic_ostream >&))
movl $.LC2, %esi
movl std::cout, %edi
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
movq %rax, %rdx
movl -16(%rbp), %eax
movl %eax, %esi
movq %rdx, %rdi
call std::basic_ostream >::operator<<(int)
movl std::basic_ostream >& std::endl >(std::basic_ostream >&), %esi
movq %rax, %rdi
call std::basic_ostream >::operator<<(std::basic_ostream >& (*)(std::basic_ostream >&))
movl $0, -4(%rbp)
.L7:
movl -4(%rbp), %eax
cltq
movzbl -1024(%rbp,%rax), %eax
testb %al, %al
je .L6
addl $1, -8(%rbp)
addl $1, -4(%rbp)
jmp .L7
.L6:
movl $.LC3, %esi
movl std::cout, %edi
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
movq %rax, %rdx
movl -8(%rbp), %eax
movl %eax, %esi
movq %rdx, %rdi
call std::basic_ostream >::operator<<(int)
movl $0, %eax
leave
ret
__static_initialization_and_destruction_0(int, int):
pushq %rbp
movq %rsp, %rbp
subq $16, %rsp
movl %edi, -4(%rbp)
movl %esi, -8(%rbp)
cmpl $1, -4(%rbp)
jne .L11
cmpl $65535, -8(%rbp)
jne .L11
movl std::__ioinit, %edi
call std::ios_base::Init::Init()
movl $__dso_handle, %edx
movl std::__ioinit, %esi
movl std::ios_base::Init::~Init(), %edi
call __cxa_atexit
.L11:
nop
leave
ret
pushq %rbp
movq %rsp, %rbp
movl $65535, %esi
movl $1, %edi
call __static_initialization_and_destruction_0(int, int)
popq %rbp
ret
Solution
Answer:
Assembly Language Code :
.zero 1
.LC0:
.string "Enter a string :"
.LC1:
.string "The number of uppercase letters are :"
.LC2:
.string "The number of lowercase letters are :"
.LC3:
.string "The total number of characters are : "
main:
pushq %rbp
movq %rsp, %rbp
subq $1024, %rsp
movl $0, -8(%rbp)
movl $0, -12(%rbp)
movl $0, -16(%rbp)
movl $.LC0, %esi
movl std::cout, %edi
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
leaq -1024(%rbp), %rax
movl $1000, %edx
movq %rax, %rsi
movl std::cin, %edi
call std::basic_istream >::getline(char*, long)
movl $0, -4(%rbp)
.L5:
movl -4(%rbp), %eax
cltq
movzbl -1024(%rbp,%rax), %eax
testb %al, %al
je .L2
movl -4(%rbp), %eax
cltq
movzbl -1024(%rbp,%rax), %eax
cmpb $64, %al
jle .L3
movl -4(%rbp), %eax
cltq
movzbl -1024(%rbp,%rax), %eax
cmpb $90, %al
jg .L3
addl $1, -12(%rbp)
.L3:
movl -4(%rbp), %eax
cltq
movzbl -1024(%rbp,%rax), %eax
cmpb $96, %al
jle .L4
movl -4(%rbp), %eax
cltq
movzbl -1024(%rbp,%rax), %eax
cmpb $122, %al
jg .L4
addl $1, -16(%rbp)
.L4:
addl $1, -4(%rbp)
jmp .L5
.L2:
movl $.LC1, %esi
movl std::cout, %edi
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
movq %rax, %rdx
movl -12(%rbp), %eax
movl %eax, %esi
movq %rdx, %rdi
call std::basic_ostream >::operator<<(int)
movl std::basic_ostream >& std::endl >(std::basic_ostream >&), %esi
movq %rax, %rdi
call std::basic_ostream >::operator<<(std::basic_ostream >& (*)(std::basic_ostream >&))
movl $.LC2, %esi
movl std::cout, %edi
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
movq %rax, %rdx
movl -16(%rbp), %eax
movl %eax, %esi
movq %rdx, %rdi
call std::basic_ostream >::operator<<(int)
movl std::basic_ostream >& std::endl >(std::basic_ostream >&), %esi
movq %rax, %rdi
call std::basic_ostream >::operator<<(std::basic_ostream >& (*)(std::basic_ostream >&))
movl $0, -4(%rbp)
.L7:
movl -4(%rbp), %eax
cltq
movzbl -1024(%rbp,%rax), %eax
testb %al, %al
je .L6
addl $1, -8(%rbp)
addl $1, -4(%rbp)
jmp .L7
.L6:
movl $.LC3, %esi
movl std::cout, %edi
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
movq %rax, %rdx
movl -8(%rbp), %eax
movl %eax, %esi
movq %rdx, %rdi
call std::basic_ostream >::operator<<(int)
movl $0, %eax
leave
ret
__static_initialization_and_destruction_0(int, int):
pushq %rbp
movq %rsp, %rbp
subq $16, %rsp
movl %edi, -4(%rbp)
movl %esi, -8(%rbp)
cmpl $1, -4(%rbp)
jne .L11
cmpl $65535, -8(%rbp)
jne .L11
movl std::__ioinit, %edi
call std::ios_base::Init::Init()
movl $__dso_handle, %edx
movl std::__ioinit, %esi
movl std::ios_base::Init::~Init(), %edi
call __cxa_atexit
.L11:
nop
leave
ret
pushq %rbp
movq %rsp, %rbp
movl $65535, %esi
movl $1, %edi
call __static_initialization_and_destruction_0(int, int)
popq %rbp
ret

AnswerAssembly Language Code .zero 1 .LC0 .string Enter.pdf

  • 1.
    Answer: Assembly Language Code: .zero 1 .LC0: .string "Enter a string :" .LC1: .string "The number of uppercase letters are :" .LC2: .string "The number of lowercase letters are :" .LC3: .string "The total number of characters are : " main: pushq %rbp movq %rsp, %rbp subq $1024, %rsp movl $0, -8(%rbp) movl $0, -12(%rbp) movl $0, -16(%rbp) movl $.LC0, %esi movl std::cout, %edi call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) leaq -1024(%rbp), %rax movl $1000, %edx movq %rax, %rsi movl std::cin, %edi call std::basic_istream >::getline(char*, long) movl $0, -4(%rbp) .L5: movl -4(%rbp), %eax cltq movzbl -1024(%rbp,%rax), %eax testb %al, %al je .L2 movl -4(%rbp), %eax cltq
  • 2.
    movzbl -1024(%rbp,%rax), %eax cmpb$64, %al jle .L3 movl -4(%rbp), %eax cltq movzbl -1024(%rbp,%rax), %eax cmpb $90, %al jg .L3 addl $1, -12(%rbp) .L3: movl -4(%rbp), %eax cltq movzbl -1024(%rbp,%rax), %eax cmpb $96, %al jle .L4 movl -4(%rbp), %eax cltq movzbl -1024(%rbp,%rax), %eax cmpb $122, %al jg .L4 addl $1, -16(%rbp) .L4: addl $1, -4(%rbp) jmp .L5 .L2: movl $.LC1, %esi movl std::cout, %edi call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) movq %rax, %rdx movl -12(%rbp), %eax movl %eax, %esi movq %rdx, %rdi call std::basic_ostream >::operator<<(int) movl std::basic_ostream >& std::endl >(std::basic_ostream >&), %esi movq %rax, %rdi call std::basic_ostream >::operator<<(std::basic_ostream >& (*)(std::basic_ostream >&))
  • 3.
    movl $.LC2, %esi movlstd::cout, %edi call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) movq %rax, %rdx movl -16(%rbp), %eax movl %eax, %esi movq %rdx, %rdi call std::basic_ostream >::operator<<(int) movl std::basic_ostream >& std::endl >(std::basic_ostream >&), %esi movq %rax, %rdi call std::basic_ostream >::operator<<(std::basic_ostream >& (*)(std::basic_ostream >&)) movl $0, -4(%rbp) .L7: movl -4(%rbp), %eax cltq movzbl -1024(%rbp,%rax), %eax testb %al, %al je .L6 addl $1, -8(%rbp) addl $1, -4(%rbp) jmp .L7 .L6: movl $.LC3, %esi movl std::cout, %edi call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) movq %rax, %rdx movl -8(%rbp), %eax movl %eax, %esi movq %rdx, %rdi call std::basic_ostream >::operator<<(int) movl $0, %eax leave ret __static_initialization_and_destruction_0(int, int): pushq %rbp movq %rsp, %rbp
  • 4.
    subq $16, %rsp movl%edi, -4(%rbp) movl %esi, -8(%rbp) cmpl $1, -4(%rbp) jne .L11 cmpl $65535, -8(%rbp) jne .L11 movl std::__ioinit, %edi call std::ios_base::Init::Init() movl $__dso_handle, %edx movl std::__ioinit, %esi movl std::ios_base::Init::~Init(), %edi call __cxa_atexit .L11: nop leave ret pushq %rbp movq %rsp, %rbp movl $65535, %esi movl $1, %edi call __static_initialization_and_destruction_0(int, int) popq %rbp ret Solution Answer: Assembly Language Code : .zero 1 .LC0: .string "Enter a string :" .LC1: .string "The number of uppercase letters are :" .LC2: .string "The number of lowercase letters are :"
  • 5.
    .LC3: .string "The totalnumber of characters are : " main: pushq %rbp movq %rsp, %rbp subq $1024, %rsp movl $0, -8(%rbp) movl $0, -12(%rbp) movl $0, -16(%rbp) movl $.LC0, %esi movl std::cout, %edi call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) leaq -1024(%rbp), %rax movl $1000, %edx movq %rax, %rsi movl std::cin, %edi call std::basic_istream >::getline(char*, long) movl $0, -4(%rbp) .L5: movl -4(%rbp), %eax cltq movzbl -1024(%rbp,%rax), %eax testb %al, %al je .L2 movl -4(%rbp), %eax cltq movzbl -1024(%rbp,%rax), %eax cmpb $64, %al jle .L3 movl -4(%rbp), %eax cltq movzbl -1024(%rbp,%rax), %eax cmpb $90, %al jg .L3 addl $1, -12(%rbp) .L3:
  • 6.
    movl -4(%rbp), %eax cltq movzbl-1024(%rbp,%rax), %eax cmpb $96, %al jle .L4 movl -4(%rbp), %eax cltq movzbl -1024(%rbp,%rax), %eax cmpb $122, %al jg .L4 addl $1, -16(%rbp) .L4: addl $1, -4(%rbp) jmp .L5 .L2: movl $.LC1, %esi movl std::cout, %edi call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) movq %rax, %rdx movl -12(%rbp), %eax movl %eax, %esi movq %rdx, %rdi call std::basic_ostream >::operator<<(int) movl std::basic_ostream >& std::endl >(std::basic_ostream >&), %esi movq %rax, %rdi call std::basic_ostream >::operator<<(std::basic_ostream >& (*)(std::basic_ostream >&)) movl $.LC2, %esi movl std::cout, %edi call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) movq %rax, %rdx movl -16(%rbp), %eax movl %eax, %esi movq %rdx, %rdi call std::basic_ostream >::operator<<(int) movl std::basic_ostream >& std::endl >(std::basic_ostream >&), %esi movq %rax, %rdi
  • 7.
    call std::basic_ostream >::operator<<(std::basic_ostream>& (*)(std::basic_ostream >&)) movl $0, -4(%rbp) .L7: movl -4(%rbp), %eax cltq movzbl -1024(%rbp,%rax), %eax testb %al, %al je .L6 addl $1, -8(%rbp) addl $1, -4(%rbp) jmp .L7 .L6: movl $.LC3, %esi movl std::cout, %edi call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) movq %rax, %rdx movl -8(%rbp), %eax movl %eax, %esi movq %rdx, %rdi call std::basic_ostream >::operator<<(int) movl $0, %eax leave ret __static_initialization_and_destruction_0(int, int): pushq %rbp movq %rsp, %rbp subq $16, %rsp movl %edi, -4(%rbp) movl %esi, -8(%rbp) cmpl $1, -4(%rbp) jne .L11 cmpl $65535, -8(%rbp) jne .L11 movl std::__ioinit, %edi call std::ios_base::Init::Init() movl $__dso_handle, %edx
  • 8.
    movl std::__ioinit, %esi movlstd::ios_base::Init::~Init(), %edi call __cxa_atexit .L11: nop leave ret pushq %rbp movq %rsp, %rbp movl $65535, %esi movl $1, %edi call __static_initialization_and_destruction_0(int, int) popq %rbp ret