LOW LEVEL X86 ASSEMBLY LANGUAGE *USING VISUAL STUDIOS You are given three intege
ID: 638565 • Letter: L
Question
LOW LEVEL X86 ASSEMBLY LANGUAGE
*USING VISUAL STUDIOS
You are given three integer numbers. You need to add the smallest number to
the largest number and multiply that sum by two.
You are NOT allowed to use any version of the MULTIPLY instruction! Shifting a binary number by one bit to left is equivalent to multiplying it by two.
Implementation details:
The three integer numbers are stored in registers eax, ebx, and ecx. You need
to store the answer into register edx.
Hint:
One way of finding minimum and maximum number is to sort the numbers.
void lab1( int a, int b, int c, int *result )
{
__asm
{
mov esi, result
push eax
push ebx
push ecx
push edx
mov eax, a
mov ebx, b
mov ecx, c
// YOUR CODE STARTS HERE
// YOUR CODE ENDS HERE
mov [esi][0], edx
pop edx
pop ecx
pop ebx
pop eax
}
return;
}
Explanation / Answer
DATA SEGMENT A DW 8,2,5,6,1,3 DATA ENDS CODE SEGMENT ASSUME DS:DATA,CS:CODE START: MOV AX,DATA MOV DS,AX MOV CX,0000 MOV CL,06 LEA BX,A MOV DX,WORD PTR[BX] MOV AX,0000 L1:CMP AX,WORD PTR[BX] JNC L2 MOV AX,WORD PTR[BX] L2:CMP DX,WORD PTR[BX] JC L3 MOV DX,WORD PTR[BX] L3:ADD BX,02 DEC CL CMP CL,00 JNZ L1 MOV AH,4CH INT 21H CODE ENDS END START ;OUTPUT:-> ;-G CS: 0028 ; ;AX=0008 BX=000C CX=0000 DX=0001 SP=0000 BP=0000 SI=0000 DI=0000 ;DS=0BF4 ES=0BE4 SS=0BF4 CS=0BF5 IP=0028 NV UP EI PL ZR NA PE NC ;0BF5:0028 B44C MOV AH,4C
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.