I. Use the Pep/8 Virtual Computer to answer the following question. Make sure th
ID: 3803749 • Letter: I
Question
I. Use the Pep/8 Virtual Computer to answer the following question. Make sure the Code/CPU/Memory view is selected.
Write a program in Assembly Language that displays your first name on the screen. Assemble/Load/Run the source code.
Copy the source code from the “Assembler Listing” window & paste it below - make sure all the program code is shown.
II. Use the Pep/8 Virtual Computer to answer the following question. Make sure the Code/CPU/Memory view is selected.
Write a program in Assembly Language that prompts the user for two numbers (i & j) and displays the result of calculating i - j + 2. Assemble/Load/Run the source code.
Copy the source code from the “Assembler Listing” window & paste it below - make sure all the program code is shown.
Explanation / Answer
Answer:
1)
.LC0:
.string "Please enter your name: "
.LC1:
.string "Your name is: "
main:
push rbp
mov rbp, rsp
sub rsp, 64
mov esi, OFFSET FLAT:.LC0
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
lea rax, [rbp-64]
mov rsi, rax
mov edi, OFFSET FLAT:std::cin
call std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char> >(std::basic_istream<char, std::char_traits<char> >&, char*)
mov esi, OFFSET FLAT:.LC1
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
mov rdx, rax
lea rax, [rbp-64]
mov rsi, rax
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 const*)
mov esi, OFFSET FLAT:std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)
mov rdi, rax
call std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))
mov eax, 0
leave
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:std::__ioinit
call std::ios_base::Init::Init()
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:std::__ioinit
mov edi, OFFSET FLAT:std::ios_base::Init::~Init()
call __cxa_atexit
.L5:
nop
leave
ret
_GLOBAL__sub_I_main:
push rbp
mov rbp, rsp
mov esi, 65535
mov edi, 1
call __static_initialization_and_destruction_0(int, int)
pop rbp
ret
2)
mov eax, DWORD PTR [rbp-4]
sub eax, DWORD PTR [rbp-8]
add eax, 2
mov DWORD PTR [rbp-12], eax