Question

In: Computer Science

Construct an assembly language program fragment equivalent to the following C/C++ statement: if (M <= N...

  1. Construct an assembly language program fragment equivalent to the following C/C++ statement:

if (M <= N + 3 && (C == ‘N’ || C == ‘n’))

C = ‘0’;

else

C = ‘1’;

Assume that M and N are 32-bit signed integer variables, and C is an 8-bit ASCII character variable. All variables are stored in memory, and all general-purpose registers are available for use.

Solutions

Expert Solution

main:

        push    rbp

        mov     rbp, rsp

        mov     eax, DWORD PTR [rbp-4]

        add     eax, 3

        cmp     DWORD PTR [rbp-8], eax

        jg      .L2

        cmp     BYTE PTR [rbp-9], 78

        je      .L3

        cmp     BYTE PTR [rbp-9], 110

jne     .L2

.L3:

        mov     BYTE PTR [rbp-9], 48

        jmp     .L4

.L2:

        mov     BYTE PTR [rbp-9], 49

.L4:

        mov     eax, 0

        pop     rbp

        ret


Related Solutions

Assembly Language Programming Construct an assembly language program fragment equivalent to the following C/C++ statement: if...
Assembly Language Programming Construct an assembly language program fragment equivalent to the following C/C++ statement: if (M <= N + 3 && (C == ‘N’ || C == ‘n’)) C = ‘0’; else C = ‘1’; Assume that M and N are 32-bit signed integer variables, and C is an 8-bit ASCII character variable. All variables are stored in memory, and all general-purpose registers are available for use.
3) Consider the following IA32 assembly language code fragment. Assume that a, b and c are...
3) Consider the following IA32 assembly language code fragment. Assume that a, b and c are integer variables declared in the data segment. movl a, %eax movl b, %ebx cmpl %ebx, %eax jge L1 movl %eax, %ecx jmp L2 L1: movl %ebx, %ecx L2: movl %ecx, c Write the C code which is equivalent to the above assembly language code. You don't need to include the variable declarations, a function or anything like that, just show the 1 to 4...
Write an assembly language program that corresponds to the following C program ****Please give correct answer...
Write an assembly language program that corresponds to the following C program ****Please give correct answer using Pep/9 machine**** int num1; int num2; ;int main () { scanf("%d", &num1); num2 = -num1; printf("num1 = %d\n", num1); printf("num2 = %d\n", num2); return 0; }
Take the following C++ program and translate it into assembly language( pep9 ) #include using namespace...
Take the following C++ program and translate it into assembly language( pep9 ) #include using namespace std; char ch; int main() {    cin >> ch;    cout << "You inputted " << ch << endl;    ch++;    cout << "Next character is " << ch << endl; if (ch <= ‘Z’)         cout << “Could be luppercase\n”;    return 0; }
ASSEMBLY LANGUAGE PROGRAMMING Q:Write a complete assembly program that inputs a small signed integer n, whose...
ASSEMBLY LANGUAGE PROGRAMMING Q:Write a complete assembly program that inputs a small signed integer n, whose value can fit within 8 bits, and outputs the value of the expression n2 – n + 6.
Complete the AVR assembly language fragment below so that it does a multiply by 2 of...
Complete the AVR assembly language fragment below so that it does a multiply by 2 of the two's complement 32-bit quantity in registers r18:r19:r20:r21. (r18 is the most significant byte.) asrlsrlslaslrolrorr18r19r20r21  asrlsrlslaslrolrorr18r19r20r21 asrlsrlslaslrolrorr18r19r20r21  asrlsrlslaslrolrorr18r19r20r21 asrlsrlslaslrolrorr18r19r20r21  asrlsrlslaslrolrorr18r19r20r21 asrlsrlslaslrolrorr18r19r20r21  asrlsrlslaslrolrorr18r19r20r21
Complete the AVR assembly language fragment below so that it performs a division by 2 of...
Complete the AVR assembly language fragment below so that it performs a division by 2 of the 24-bit two's complement value in registers r6:r5:r4. (r6 is the most significant byte.) lslasllsrasrrolrorr4r5r6  lslasllsrasrrolrorr4r5r6 lslasllsrasrrolrorr4r5r6  lslasllsrasrrolrorr4r5r6 lslasllsrasrrolrorr4r5r6  lslasllsrasrrolrorr4r5r6
Convert the following C++ statements to an ARM assembly language program: const int size = 10;...
Convert the following C++ statements to an ARM assembly language program: const int size = 10; int x[size] = {8, 2, 9, 6, 7, 0, 1, 3, 5, 4}; int y[size] = {399, -87, 12, 0, 42, -367, 57, 92, -1000, 25}; for i = 0; i < size; i++) if (x([ i ] > y[ i ]) z[ i ] = 0 else z[ i ] = 1;
Translate the following C program into MIPS assembly language, allocate registers as you need, but document...
Translate the following C program into MIPS assembly language, allocate registers as you need, but document the allocation. int A[10]; // assume initialized elsewhere int sum = 0; int I = 0; while (i<0) { sum += A[i++]; sum+= 2 ;} plz do not copy from other answer, thx.
Question 1 a) Determine whether the language {a n b m c n | n >...
Question 1 a) Determine whether the language {a n b m c n | n > 0} is regular or not using pumping Lemma. b) Prove that the language {(ai bn | i, n > 0, i = n or i = 2n} is not regular using the Pumping Lemma.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT