Question

In: Computer Science

Translate the following C++ program to Pep/9 assembly language. const char chConst = '+'; char ch1;...

Translate the following C++ program to Pep/9 assembly language.

const char chConst = '+';
char ch1;
char ch2;

int main() {
cin.get(ch1);
cin.get(ch2)
;
   cout << ch1 << chConst << ch2;
   return 0;
}

Solutions

Expert Solution

Hello. Here is your required code in assembly language. Also, please "DROP" A LIKE ON THE POST. I REALLY NEED IT.

//THIS IS THE EXACT CODE OF YOUR GIVEN SNIPPET. PLS DROP A LIKE ON IT. IF YOU NEED ANY CLARIFICATION, FEEL FREE TO COMMENT DOWN, I'LL REVERT YOU ASAP

ch1:

        .zero   1

ch2:

        .zero   1

main:

        push    rbp

        mov     rbp, rsp

        mov     esi, OFFSET FLAT:ch1

        mov     edi, OFFSET FLAT:_ZSt3cin

        call    std::basic_istream<char, std::char_traits<char> >::get(char&)

        mov     esi, OFFSET FLAT:ch2

        mov     edi, OFFSET FLAT:_ZSt3cin

        call    std::basic_istream<char, std::char_traits<char> >::get(char&)

        movzx   eax, BYTE PTR ch1[rip]

        movsx   eax, al

        mov     esi, eax

        mov     edi, OFFSET FLAT:_ZSt4cout

        call    std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char)

        mov     esi, 43

        mov     rdi, rax

        call    std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char)

        mov     rdx, rax

        movzx   eax, BYTE PTR ch2[rip]

        movsx   eax, al

        mov     esi, eax

        mov     rdi, rdx

        call    std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char)

        mov     eax, 0

        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     .L5

        cmp     DWORD PTR [rbp-8], 65535

        jne     .L5

        mov     edi, OFFSET FLAT:_ZStL8__ioinit

        call    std::ios_base::Init::Init() [complete object constructor]

        mov     edx, OFFSET FLAT:__dso_handle

        mov     esi, OFFSET FLAT:_ZStL8__ioinit

        mov     edi, OFFSET FLAT:_ZNSt8ios_base4InitD1Ev

        call    __cxa_atexit

.L5:

        nop

        leave

        ret

_GLOBAL__sub_I_ch1:

        push    rbp

        mov     rbp, rsp

        mov     esi, 65535

        mov     edi, 1

        call    __static_initialization_and_destruction_0(int, int)

        pop     rbp

        ret


Related Solutions

Take the following C++ program and translate it into Pep/9 assembly language #include using namespace std;...
Take the following C++ program and translate it into Pep/9 assembly language #include using namespace std; int age; char first, last; int main() {    cin >> age;    cin >> first >> last;    cout << "Your age " << age << endl;    cout << "Initials " << first << last << endl;    if (age >= 30)        cout << “Cannot trust\n”;    return 0; }
Take the following C++ program and translate it into PEP/9 assembly language #include <iostream> using namespace...
Take the following C++ program and translate it into PEP/9 assembly language #include <iostream> using namespace std; int num; char letter; int main() {    cin >> num;    cin >> letter;    cout << "You inputted " << num << endl;    cout << "Option " << letter << endl;    if (letter == '*')       cout << "Multiplied by 2 " << num*2 << endl;    return 0; }
Take the following program from C++ and translate it into Pep/9 assembly language: #include <iostream> using...
Take the following program from C++ and translate it into Pep/9 assembly language: #include <iostream> using namespace std; int theArray[] = { 5, 11, -29, 45, 9, -1}; void sumPos(int ary[], int len, int &sum) {    sum = 0;    for (int i = 0; i < len; i++)            if (ary[i] > 0)                sum = sum + ary[i]; } int main() {    int total;    sumPos(theArray, 6, total);    for (int k=0; k < 6; k++)...
Translate the following C program to PEP/9 assembly language. #include <stdio.h> Int main (){ int number;...
Translate the following C program to PEP/9 assembly language. #include <stdio.h> Int main (){ int number; Scanf (“%d”, & number); if (number % 2 ==0) { printf (“Even\n”); } else { printf(“Odd\n”); } Return 0; }
Take the following program and translate it into PEP/9 assembly language: #include <iostream> using namespace std;...
Take the following program and translate it into PEP/9 assembly language: #include <iostream> using namespace std; int theArray[] = { 5, 11, -29, 45, 9, -1}; void sumPos(int ary[], int len, int &sum) {    sum = 0;    for (int i = 0; i < len; i++)            if (ary[i] > 0)                sum = sum + ary[i]; } int main() {    int total;    sumPos(theArray, 6, total);    for (int k=0; k < 6; k++)      cout...
Take the following program and translate it into PEP/9 assembly language: #include using namespace std; int...
Take the following program and translate it into PEP/9 assembly language: #include using namespace std; int fib(int n) { int temp; if (n <= 0) return 0; else if (n <= 2) return 1; else { temp = fib(n – 1); return temp + fib(n-2); } } int main() { int num; cout << "Which fibonacci number? "; cin >> num; cout << fib(num) << endl; return 0; } You must use equates to access the stack and follow the...
Translate the following C program to Pep/9 assembly language. #include <stdio.h.> int main() { int numitms,j,data,sum;...
Translate the following C program to Pep/9 assembly language. #include <stdio.h.> int main() { int numitms,j,data,sum; scanf("%d", &numitms); sum=0; for (j=1;j<=numitms;j++) { scanf("%d", &data); sum+=data; } printf("sum: %d\n",sum); return0; } I got an answer with an error. Please debug the answer or have a new correct answer (don't copy and paste others' answer) main: SUBSP 2,i DECI numItms,i DECI j,j DECI data,d DECI sum,s LDWA numItms,i sum: .EQUATE 0 LDWA 1,i STWA j,j for: CPWA numItms, j BRGE endFor STRO...
Take the following C++ program and translate it into assembly language( pep9 ) #include using namespace...
Take the following C++ program and translate it into assembly language( pep9 ) #include using namespace std; char ch; int main() {    cin >> ch;    cout << "You inputted " << ch << endl;    ch++;    cout << "Next character is " << ch << endl; if (ch <= ‘Z’)         cout << “Could be luppercase\n”;    return 0; }
Convert the following C++ statements to an ARM assembly language program: const int size = 10;...
Convert the following C++ statements to an ARM assembly language program: const int size = 10; int x[size] = {8, 2, 9, 6, 7, 0, 1, 3, 5, 4}; int y[size] = {399, -87, 12, 0, 42, -367, 57, 92, -1000, 25}; for i = 0; i < size; i++) if (x([ i ] > y[ i ]) z[ i ] = 0 else z[ i ] = 1;
Assembly Language Programming Construct an assembly language program fragment equivalent to the following C/C++ statement: if...
Assembly Language Programming Construct an assembly language program fragment equivalent to the following C/C++ statement: if (M <= N + 3 && (C == ‘N’ || C == ‘n’)) C = ‘0’; else C = ‘1’; Assume that M and N are 32-bit signed integer variables, and C is an 8-bit ASCII character variable. All variables are stored in memory, and all general-purpose registers are available for use.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT