2. (8 pts) Comment eadc assembly instruction; rather explain what it is omment e
ID: 3859986 • Letter: 2
Question
2. (8 pts) Comment eadc assembly instruction; rather explain what it is omment each line of assembly code· Do not just explain the doing. Example: mov eax,0 BAD> moving a zero into eax GOOD>setting counter to zero Given: char limit- o, 16, 8, o, 4ebp-14h] , lebp-14h1 16, -14h] 0, [ebp-14h+1 etc -- .. 004018A8 C6 45 FF 00 mov [ebp-11,0 004018AC EB 08 jmp short loc 4018B6 BA 45 FF al, [ebp-1] mov 004018B1 04 01 add al, al, 1 mov ebp-1], al 004018B3 88 45 FF movsx ecx, [ebp-1] 004018B6 OF BE 4D FF edx, [ebp-8] i local var 004018BA 8B 55 F8 movsx eax, [ebptedx-14h] array "iimit" 004018BD OF BE 44 15 EC cmpecx, eax 004018C2 3B C8 Page 2 2017 06-CS 3843 Computer Organization HomeworkExplanation / Answer
Answer 1. Details description of assembly code:-
mov [ebp-1], 0 // used to access data on stack here we store 0 to base pointer on top of the stack
jmp short loc_4018B6 // it is shortly jump to location as mention loc_4018B6
movsx ecx, [ebp-1] // control start executing from this line and move top letter to ECX register
mov edx, [ebp-8] ; local variable // Writing data from [ebp - 8] to register EDX is bad here because it will destroy the value of saved register
movsx eax , [ebp+edx-14h]
cmp ecx , eax // This is important for programmer to check,if the ECX register is zero then the repe cmpsb is not executed at all.
jge short loc_4018F6 // Jump if greater or equal to location as mention loc_4018F6
mov ecx, [ebp-8] // Writing data from [ebp - 8] to register ECX
push ecx // It pushes the value of ECX on the stack
movsx edx , [ebp-1] // moving data to register EDX
push edx // // It pushes the value of EDX on the stack
call getNumber
add esp, 8 // simply it adds the value 8 to register ESP , here we also we can use pop but here we can clean the stack by add function
mov [ebp-0Ch], eax // moving value of register EAX to [ebp-0Ch]
jmp short loc_4018AB // jump to third line of assembly code where it move value of [ebp-1] to
mov a1, [ebp-1]
Answer 2. Function what this is doing:-
getNumber(int a, int b) {
int c = a + b;
return c;
}
main() {
return getNumber(10,20);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.