1 Write a simple assembly code that places a 16 bit number o
1. Write a simple assembly code, that places a 16 bit number of your choice in accumulator D, and then stores the contents of accumulator D in a particular memory location. using assemmbly language
Solution
Answer:
MIPS Assembly Language Code :
.zero 1
 .LC0:
 .string \"The 16 bit number is:\"
 main:
 push rbp
 mov rbp, rsp
 push rbx
 sub rsp, 24
 mov BYTE PTR [rbp-17], 122
 movzx eax, BYTE PTR [rbp-17]
 mov BYTE PTR [rbp-18], al
 movsx ebx, BYTE PTR [rbp-18]
 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*)
 mov esi, ebx
 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 eax, 0
 add rsp, 24
 pop rbx
 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: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
 push rbp
 mov rbp, rsp
 mov esi, 65535
 mov edi, 1
 call __static_initialization_and_destruction_0(int, int)
 pop rbp
 ret

