In: Computer Science
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;
}
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