Problem #2 (25 points) MSP430 Addressing Modes, Instruction Encoding Consider th
ID: 3742416 • Letter: P
Question
Problem #2 (25 points) MSP430 Addressing Modes, Instruction Encoding Consider the following instructions given in the table below. For each instruction determine its length (in words), the instruction words (in hexadecimal), source operand addressing mode, and the content of register R7 after execution of each instruction. Fill in the empty cells in the table. The initial content of memory is given below. Initial value of registers R5, R6, and R7 is as follows: RS-0xF002, R6-0xF0OA, R8-0xFF88. Assume the starting conditions are the same for each The format of the first word of double-operand instructions is shown below.(Note: Op-code for MOV is 0100b). Op-code s Reg D Reg Instr. Address Instruction Instr. Instruction Word(s) Source OperandR8- Length HEXI 10x1116 | MOV R5. RS | 1 1014508 (RS),R&014548 Addressing HEX words Mode |Register Register (i)0x6 MOV.B R5, R8 0x0002 (a) 0x116 MOV 4(RS), RS (6)0x1116 MOV.B 3(R5), R8 (c) 0x116 MOV.B -3(R6), R8 (d) 0x1116 MOV TONI, R8 (e) Ox116 MOV.B EDE, R8 (t Oxl16 MOV &EDE, R8 (g) 0xl116 MOV.B @R5, R8 (h) 0xl116 MOV @R5+, R8 (i) |0x1116 MOW #45, R8 11 16 | MOV.BA45. RS | Or oa0 oorf selte Label Address [hex Memory 15:0 Thex) 0xF000 0xF002 TONI 0xF004 0xF006 0xF008 0x0504 OxFFEE 0xCC06 0x3304 0xF014 0x2244 OxFOOA 0xFOOEExplanation / Answer
Answer:
.LC0:
.string "Enter the number to convert: "
.LC1:
.string "Binary of the given number= "
main:
push rbp
mov rbp, rsp
sub rsp, 64
mov esi, OFFSET FLAT:.LC0
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 const*)
lea rax, [rbp-52]
mov rsi, rax
mov edi, OFFSET FLAT:_ZSt3cin
call std::basic_istream<char, std::char_traits<char> >::operator>>(int&)
mov DWORD PTR [rbp-4], 0
.L3:
mov eax, DWORD PTR [rbp-52]
test eax, eax
jle .L2
mov eax, DWORD PTR [rbp-52]
cdq
shr edx, 31
add eax, edx
and eax, 1
sub eax, edx
mov edx, eax
mov eax, DWORD PTR [rbp-4]
cdqe
mov DWORD PTR [rbp-48+rax*4], edx
mov eax, DWORD PTR [rbp-52]
mov edx, eax
shr edx, 31
add eax, edx
sar eax
mov DWORD PTR [rbp-52], eax
add DWORD PTR [rbp-4], 1
jmp .L3
.L2:
mov esi, OFFSET FLAT:.LC1
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 const*)
sub DWORD PTR [rbp-4], 1
.L5:
cmp DWORD PTR [rbp-4], 0
js .L4
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-48+rax*4]
mov esi, eax
mov edi, OFFSET FLAT:_ZSt4cout
call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
sub DWORD PTR [rbp-4], 1
jmp .L5
.L4:
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 .L9
cmp DWORD PTR [rbp-8], 65535
jne .L9
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
.L9:
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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.