// template.cpp : Defines the entry point for the console application. // #inclu
ID: 1832557 • Letter: #
Question
// template.cpp : Defines the entry point for the console application.//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
__asm
{
//1) Place 7 in the EAX register, place 5 in EBX, add the two numbers together, and have the result go into the EAX register
//2) Place 4 in the EAX register, shift the bits left 3 times, with the result in the EAX register
//3) Loop 3 times, using the fewest number of instructions that you can.
//4) Push the 32bit value 6 on the stack, then pop it off the stack into the EAX register
//5) Place 2 in the AX register, compare AX to the number 5, do a conditional branch (jump) if AX is greater than or equal to 5
}
return 0;
}
Explanation / Answer
//1) Place 7 in the EAX register, place 5 in EBX, add the two numbers together, and have the result go into the EAX register
mov EAX, 7;
mov EBX , 5;
add EAX, EBX;
//2) Place 4 in the EAX register, shift the bits left 3 times, with the result in the EAX register
mov EAX, 4;
shl EAX, 3
//3) Loop 3 times, using the fewest number of instructions that you can.
// one way to do this is as follows
mov ECX , 3;
start:
loop start; // loop repeats ECX times
// other way is as follows
mov ECX, 3;
start:
dec ECX, 1;
jnz start;
//4) Push the 32bit value 6 on the stack, then pop it off the stack into the EAX register
mov EBX, 0xFFFFFFFF ;
push EBX;
pop EAX;
//5) Place 2 in the AX register, compare AX to the number 5, do a conditional branch (jump) if AX is greater than or equal to 5
mov ax, 2;
cmp ax, 5;
jge LABEL; // This jump is taken after a CMP if the signed destination is larger than
//or equal to the signed source
LABEL:
Hope this helps...
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.