Convert the high level language programming statementts to 80x86 assembly, Assume X=AX and y=BX
for (i=1; i<10; ++i){
x=x+1;
y=y-1;
}
if(x>=y)
y=x-1;
else
y=x+1;
Question:
Convert the high level language programming statementts to 80x86 assembly, Assume X=AX and y=BX
for (i=1; i<10; ++i){
x=x+1;
y=y-1;
}
if(x>=y)
y=x-1;
else
y=x+1;
Answer with Clear Information:
Above High Level Code need to be modified as shown below to make it compatible with gcc/g++ compiler options.
Modified code is mentioned in bold
void main()
{
int i,x,y;
for (i=1; i<10; ++i){
x=x+1;
y=y-1;
}
if(x>=y)
y=x-1;
else
y=x+1;
}
After changing the above code, it was compiled and executed properly.
8086 Assembly Code for the same is written as follows:
==============================================
_i$ = -12 ; size = 4
_y$ = -8 ; size = 4
_x$ = -4 ; size = 4
_main PROC
push ebp
mov ebp, esp
sub esp, 12 ; 0000000cH
mov DWORD PTR _i$[ebp], 1
jmp SHORT $LN4@main
$LN2@main:
mov eax, DWORD PTR _i$[ebp]
add eax, 1
mov DWORD PTR _i$[ebp], eax
$LN4@main:
cmp DWORD PTR _i$[ebp], 10 ; 0000000aH
jge SHORT $LN3@main
mov ecx, DWORD PTR _x$[ebp]
add ecx, 1
mov DWORD PTR _x$[ebp], ecx
mov edx, DWORD PTR _y$[ebp]
sub edx, 1
mov DWORD PTR _y$[ebp], edx
jmp SHORT $LN2@main
$LN3@main:
mov eax, DWORD PTR _x$[ebp]
cmp eax, DWORD PTR _y$[ebp]
jl SHORT $LN5@main
mov ecx, DWORD PTR _x$[ebp]
sub ecx, 1
mov DWORD PTR _y$[ebp], ecx
jmp SHORT $LN1@main
$LN5@main:
mov edx, DWORD PTR _x$[ebp]
add edx, 1
mov DWORD PTR _y$[ebp], edx
$LN1@main:
xor eax, eax
mov esp, ebp
pop ebp
ret 0
_main ENDP
==============================================
Compile and Execute the above 8086 Assembly Code in 8085/8086 compatible operating systems. Validate and Verify the output results.
Convert the high level language programming statementts to 80x86 assembly, Assume X=AX and y=BX for (i=1;...
using Ax register convert this high-level language expression to Assembly language code - C=C+4 - C=C-1
Convert the following c code into instructions MIPS Assembly language. Assume a associated with $s0, i with $s1, and j with $s2. if( i < 10) { if( j < 10) { a = 0; } else { a = 1;} } else { a = 2; }
please do not copy from previous posted answer
troduc... (IOpts) y=bx 7. Translate the following C-code control structures into 80x86 assembly Use x=ax a) while (x <=y) { x=x+4; y= y-8; } X=y; b) if(y>x) { if(x==2) y=1; else y=2; x=y;
Exercise 1: For each of the following high-level language code snippets, write the SRO assembly code. Assume that the variables A, B, C, X. are in memory locations MA, MB, MC, MX, respectively. a) XA+ 2B- 4C; b) if (A <0) else if (A> 0) else c) for (int i 1; 10; i++) X A+B+C (Hint: Use branch instructions to set up the loop)
For exercises 3 through 5: .Convert the given high level language pseudocode into MIPS assembly * Use proper indentation for code blocks within conditional statements and loops Comment each assembly instruction to indicate the high-level language operation it is performing: .Use MARS to verify correct operation of your program
Convert the following C fragment to equivalent MIPS assembly language. Assume that the variables a, b, c, d, i and x are assigened to registers $t1, $t2, $t3, $t4, $s0 and $s1 respectively. Assume that the base address of the array A and B is in register $a0 and $a1 respectively. if (a > 0) b = a + 10; else b = a - 10;
Write a sequence of normal assembly language instructions corresponding to the following sequence of high-level language statements. Assume that each variable (A, B. C, and D) is one word in memory. If notequalto B then C: =5; else C: =10; D: =50;
(10 points) Translate the following algorithm into assembly
language. IF 65 < X THEN X = 9+(X^2) ELSE X = - Y 3.
(10 points) Translate the following algorithm into assembly
language. X=0 FOR K = I TO 5 X=X+5 END_FOR
4. (10 points) Translate the
following algorithm into assembly language. X=0 Y=5 Z=5 WHILE Z = 5
X=X+1 Y=Y-1 Z=X+Y
2. (10 points) Translate the following algorithm into assembly language. IF65 < X THEN X = 9t(X^2) ELSE X...
5. Assume DS-1000, CS- 800, Ax-3412H, and BX-0200H. For the following x86 assembly code: MOV [BX +1000H], AX a) Translate the assembly code to machine code (in Hex). The opcode of MOV instruction is 100010. b) Show the values of AX, BX, and new values in memory, if there are, in the following figure c) (10 points) AFTER executing the instruction. (5 points) What is the memory address accessed by the instruction, assuming real mode operation? Show it in the...
Which one of the following statements is FALSE? Pseudocode is a high-level programming language. C++ and Java are 3GLs – procedural languages. SQL is 4GL – non-procedural language. Assembly language is 2GL – low level language. 5GLs are much closer to natural languages.