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

Translate the program below into PEP/8 assembly language: Use a jump table to im

ID: 3758082 • Letter: T

Question

Translate the program below into PEP/8 assembly language:

Use a jump table to implement the switch statement.
Use trace tags on all variables.

#include
using namespace std;
int main () {
int finish;
cout << "Enter your score: 1, 2, 3, 4, or 5" << endl;
cin >> finish;
switch (finish) {
case 1:
cout << "you're first!" << endl;
break;
case 2:
cout << "you're second!" << endl;
break;
case 3: case 4:
cout << "you're not first or second" << endl;
break;

default:
cout << "you weren't even competing" << endl;
}
cout << endl;
return 0;
}

Explanation / Answer

Answer :

   .Ltext0:
       
    .LC0:
0000 456E7465        .string   "Enter your score: 1, 2, 3, 4, or 5"
7220796F
75722073
636F7265
3A20312C
    .LC1:
0023 796F7527        .string   "you're first!"
72652066
69727374
2100
    .LC2:
0031 796F7527        .string   "you're second!"
72652073
65636F6E
642100
    .LC3:
0040 796F7527        .string   "you're not first or second"
7265206E
6F742066
69727374
206F7220
    .LC4:
005b 796F7520        .string   "you weren't even competing"
77657265
6E277420
6576656E
20636F6D
        .text
        .globl   main
    main:
    .LFB971:
       
0000 55        pushq   %rbp
       
   
0001 4889E5        movq   %rsp, %rbp
       
0004 4883EC10        subq   $16, %rsp
    .LBB2:
0008 BE000000        movl   $.LC0, %esi
00
000d BF000000        movl   $_ZSt4cout, %edi
00
0012 E8000000        call   _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
00
0017 BE000000        movl   $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_, %esi
00
001c 4889C7        movq   %rax, %rdi
001f E8000000        call   _ZNSolsEPFRSoS_E
00
0024 488D45FC        leaq   -4(%rbp), %rax
0028 4889C6        movq   %rax, %rsi
002b BF000000        movl   $_ZSt3cin, %edi
00
0030 E8000000        call   _ZNSirsERi
00
0035 8B45FC        movl   -4(%rbp), %eax
0038 83F802        cmpl   $2, %eax
003b 7431        je   .L3
003d 83F802        cmpl   $2, %eax
0040 7F07        jg   .L4
0042 83F801        cmpl   $1, %eax
0045 7409        je   .L5
0047 EB61        jmp   .L2
    .L4:
0049 83F804        cmpl   $4, %eax
004c 7F5C        jg   .L2
004e EB3C        jmp   .L9
    .L5:
0050 BE000000        movl   $.LC1, %esi
00
0055 BF000000        movl   $_ZSt4cout, %edi
00
005a E8000000        call   _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
00
005f BE000000        movl   $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_, %esi
00
0064 4889C7        movq   %rax, %rdi
0067 E8000000        call   _ZNSolsEPFRSoS_E
00
006c EB58        jmp   .L7
    .L3:
006e BE000000        movl   $.LC2, %esi
00
0073 BF000000        movl   $_ZSt4cout, %edi
00
0078 E8000000        call   _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
00
007d BE000000        movl   $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_, %esi
00
0082 4889C7        movq   %rax, %rdi
0085 E8000000        call   _ZNSolsEPFRSoS_E
00
008a EB3A        jmp   .L7
    .L9:
008c BE000000        movl   $.LC3, %esi
00
0091 BF000000        movl   $_ZSt4cout, %edi
00
0096 E8000000        call   _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
00
009b BE000000        movl   $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_, %esi
00
00a0 4889C7        movq   %rax, %rdi
00a3 E8000000        call   _ZNSolsEPFRSoS_E
00
00a8 EB1C        jmp   .L7
    .L2:
00aa BE000000        movl   $.LC4, %esi
00
00af BF000000        movl   $_ZSt4cout, %edi
00
00b4 E8000000        call   _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
00
00b9 BE000000        movl   $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_, %esi
00
00be 4889C7        movq   %rax, %rdi
00c1 E8000000        call   _ZNSolsEPFRSoS_E
00
    .L7:
00c6 BE000000        movl   $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_, %esi
00
00cb BF000000        movl   $_ZSt4cout, %edi
00
00d0 E8000000        call   _ZNSolsEPFRSoS_E
00
00d5 B8000000        movl   $0, %eax
00
    .LBE2:
00da C9        leave
       
00db C3        ret
       
    .LFE971:
    _Z41__static_initialization_and_destruction_0ii:
    .LFB980:
00f9 BF000000        movl   $_ZStL8__ioinit, %edi
00
00fe E8000000        call   _ZNSt8ios_base4InitC1Ev
00
0103 BA000000        movl   $__dso_handle, %edx
00
0108 BE000000        movl   $_ZStL8__ioinit, %esi
00
010d BF000000        movl   $_ZNSt8ios_base4InitD1Ev, %edi
00
0112 E8000000        call   __cxa_atexit
00
       
00dc 55        pushq   %rbp
       
00dd 4889E5        movq   %rsp, %rbp
       
00e0 4883EC10        subq   $16, %rsp
00e4 897DFC        movl   %edi, -4(%rbp)
00e7 8975F8        movl   %esi, -8(%rbp)
00ea 837DFC01        cmpl   $1, -4(%rbp)
00ee 7527        jne   .L10
00f0 817DF8FF        cmpl   $65535, -8(%rbp)
FF0000
00f7 751E        jne   .L10
    .L10:
0117 C9        leave
       
0118 C3        ret
       
    .LFE980:
    _GLOBAL__sub_I_main:
    .LFB981:
       
0119 55        pushq   %rbp
       
   
011a 4889E5        movq   %rsp, %rbp
       
011d BEFFFF00        movl   $65535, %esi
00
0122 BF010000        movl   $1, %edi
00
0127 E8B0FFFF        call   _Z41__static_initialization_and_destruction_0ii
FF
012c 5D        popq   %rbp
       
012d C3        ret
   
    .LFE981:
        .section   .init_array,"aw"
        .align 8
0000 00000000        .quad   _GLOBAL__sub_I_main
00000000
        .text
    .Letext0:

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