Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Is it possible to translate this program to pep/8 assembler language not any oth

ID: 3568335 • Letter: I

Question

Is it possible to translate this program to pep/8 assembler language not any other assembly language types.

since I am using computer systems fourth edition J. stanley warford, any help will be apperciated.

Translate the following C++ program into pep/8 assembly language:

Translate the following C++ program into assembly language:

#include <iostream>

using namespace std;

int main() {

char letter;

int countA = 0,

       countB = 0,

       countC = 0;

cin >> letter;

do {

     switch (letter) {

        case 'A' : countA++; break;

        case 'B' : countB++; break;

        case 'C' : countC++; break;

      }

     cin >> letter;

} while (letter != 'X');

cout << "Number of A's " << countA << endl

         << "Number of B's " << countB << endl

         << "Number of C's " << countC << endl;

return 0;

}

Use local variables (except for messages, of course) and the branch indexed for the switch statement

Explanation / Answer

main:

      pushq %rbp

      movq %rsp, %rbp

      subq $16, %rsp

      movl $0, -12(%rbp)

      movl $0, -8(%rbp)

      movl $0, -4(%rbp)

      leaq -13(%rbp), %rax

      movq %rax, %rsi

      movl $_ZSt3cin, %edi

      call _ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_

      movzbl      -13(%rbp), %eax

      movsbl      %al, %eax

      cmpl $66, %eax

      je    .L3

      cmpl $67, %eax

      je    .L4

      cmpl $65, %eax

      jne   .L2

      addl $1, -12(%rbp)

      jmp   .L2

      addl $1, -8(%rbp)

      addl $1, -4(%rbp)

      nop

      cmpb $88, %al

      jne   .L6

      leaq -13(%rbp), %rax

      movq %rax, %rsi

      movl $_ZSt3cin, %edi

      call_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_

      movzbl      -13(%rbp), %eax

      movl $.LC0, %esi

      movl $_ZSt4cout, %edi

      call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc

      movl -12(%rbp), %edx

      movl %edx, %esi

      movq %rax, %rdi

      call _ZNSolsEi

      movl $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_,%esi   

      movq %rax, %rdi

      call _ZNSolsEPFRSoS_E

      movl $.LC1, %esi

      movq %rax, %rdi

      call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc

      movl -8(%rbp), %edx

      movl %edx, %esi

      movq %rax, %rdi

      call _ZNSolsEi

      movl $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_,%esi

      movq %rax, %rdi

      call _ZNSolsEPFRSoS_E

      movl $.LC2, %esi

      movq %rax, %rdi

      call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc

      movl -4(%rbp), %edx

      movl %edx, %esi

      movq %rax, %rdi

      call _ZNSolsEi

      movl       $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_,%esi

      movq %rax, %rdi

      call _ZNSolsEPFRSoS_E

      movl $0, %eax

      jmp   .L10

      movq %rax, %rdi

      call _Unwind_Resume

      leave

      ret

      movl $_ZStL8__ioinit, %edi

      call _ZNSt8ios_base4InitC1Ev

      movl $__dso_handle, %edx

      movl $_ZStL8__ioinit, %esi

      movl $_ZNSt8ios_base4InitD1Ev, %edi

      call __cxa_atexit

      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

      leave

      ret

      pushq %rbp

      movq %rsp, %rbp

      movl $65535, %esi

      movl $1, %edi

      call _Z41__static_initialization_and_destruction_0ii FF

      popq %rbp

      ret

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote