Assembly Language 8086 INFORMATION: Assume when we start ESP has the value $2000
ID: 648553 • Letter: A
Question
Assembly Language 8086
INFORMATION:
Assume when we start ESP has the value $2000
MOVL $0X34EF, %EAX
MOVL $0X55, %EBX
MOVL %EBX, %ECX
ADDL $8, %ECX
MOVL %ECX, %EDX
PUSHL %EAX
PUSH %EBX
PUSH %ECX
PUSH %EDX
MOVL $0, %EAX
MOVL $5, %EBX
MOVL $9, %ECX
MOVL $7, %EDX
This is what happens I think:
ESP is the stack pointer.
A = 34EF
B = 55
C = EB
mov B to C, so c = 55
Add 8 with C so 55 + 8 = 63
mov c,d so d = 63
push a so stack will have 34EF esp = 2000
push b , so stack will have 34EF, 55 esp = 2001
push c stack = 34EF, 55, 55, esp = 2002
push d 34EF, 55, 55, 63 esp = 2003
mov 0 to a, so a=0
mov 5 to b, so b = 5
mov 9 to c, so c = 9
mov 7 to d, so d = 7
QUESTION:
1) If we want to retrieve the original values back into the registers, list the instructions needed.
2) Write a procedure to add the value of EAX 10 times to itself. Use a loop inside the function. Use register ECX as a loop counter. Write the main program to place 5 into EAX and 2 in ECX and then call the function. After the return of the function the value of ECX must be 2 again but the value of EAX must be 50.
Explanation / Answer
1. for the first part
POP %EDX
POP %ECX
POP %EBX
POP %EAX
2. MOV %EAX ,$05;
MOV %ECX ,$02;
PUSH %ECX;
Label_X: ADD %EAX,$05;
ADD %ECX,$02;
CMP %ECX, 20;
JL Label_X;
POP %ECX;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.