Write an assembly language code for the following pseudo code
i. if(op1 == op2)
x=1;
else x=2;
using x86 assembly language
Solution:
MOV AX,op1
MOV BX,op2
IF: CMP AX,BX
JE TAG
JNE ELSE
ELSE:
MOV CX,#2
MOV X,CX
JMP ENFIF
TAG:
MOV CX,#1
MOV X,CX
JMP ENFIF
ENDIF:
Explanation:
Initially we move op1 and op2 to AX and BX registers.
Now we check the if condition, compare AX and BX.
JE - Jump if equal
JNE - Jump if not equal.
If AX and BX are equal, TAG label statements gets executed.
Else the Else label statements gets executed.
TAG:
We move value 1 to CX register and then to location X
ELSE:
We move value 2 to CX register and then to location X
Write an assembly language code for the following pseudo code i. if(op1 == op2) x=1; else...
Write an assembly language code Irvine32.inc x86 for the following pseudo code. Use Conditional jump If (op1 == op2) X=1; Else X=2; While (EAX < EBX) EAX = EAX + 1 ;
7. Write the following code segment in MARIE's assembly language (If-Else): If x < Y Then X = Y - X; Y = Y + 1; Else X = Y; Y = 0; Endif;
Assembly Language 64- bit system Description: You are responsible to implement several assembly functions to perform the simple arithmetic calculations for 2 64-bit integers. These functions will use the C function signature but the main logic within this function should be inline assembly code using the ASM block similar to the assembly example shown in class. 1. long XOR ( long op1, long op2 )- xor will return the result of bit exclusive OR of op1 / op2- can use...
Given the following pseudo code: int result; (result is 1 byte) int count; (count is 1 byte) for (result= 10, count= -10; count < result ; count++) { if(count > 2) result--; else result ++; } 1) write an assembly language program that will implement this pseudo code using a while construct. 2) write an assembly language program that will implement this pseudo code using a do-until construct Note: For both 1) and 2), do not forget to include the...
I am trying to understand the following code I found in a website so that I can use it for a project that evaluates boolean expressions. The code is below but I think it is in java because I do not understand it. Can you help me describe what it is doing in c++ so that I can understand it better? The link to the code is here: https://stackoverflow.com/questions/16762057/algorithm-to-evaluate-value-of-boolean-expression The code is below: public static boolean evaluateBool(String s) { Stack<Object>...
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)
Write the following code segment in MARIE's assembly language: if X < 1 then Y = X - 2; X = 0; endif; Y = Y + 7;
Please help and answer in a PSEUDO Code format in assembly language! Thanks PROJECT (a) write a program that will convert the number 23567 => n, where (b) Write an algorithm that will convert a number n, to ne where b , c < 10.
IF statement is translated into assembly language with a o CMP instruction followed by Conditional jumps. If op1 or op2 is a memory operand o IF Statemert (a variable): o one of them must be moved Problem 3: Implement the following pseudocode in assembly language. to a register before executing CMP. All values are unsigned: стр ьї, ci ja next mov al,5 mov dl,6 al-50 dl-23 next: Add to the above code the mov instructions and assign values to bl,...
Write the pseudo code using modules for the following questions 1.) write pseudo code for a program that outputs every number from 1 through 20 along with their values doubled and tripled 2.) write pseudo code for a program that outputs every number in reverse order from 25 down to 0