Question

In: Computer Science

Complete the corresponding assembly language fragments by selecting the correct instruction, register, or value: (Choices in...

Complete the corresponding assembly language fragments by selecting the correct instruction, register, or value: (Choices in bold)

a) Consider the following fragment of C code:

if(a == b) {

       x += 10;

       A[50] = A[50] +x;

}

else {

        y += 10;

        A[50] = A[50] + y;

}

Assume that variables a, b, x and y are assigned to $s0, $s1, $s2 and $s3 respectively and the base address for array A is in $s4. Only register $t0 is used for storing results temporarily.

bne $s0, ($s0 / $s1 / $s2 / $s3 / $s4 / $t0), else

addi $s2, $s2, 10

lw $t0, (0 / 10 / 50 / 200 / $s1 / $t0) ($s4)

add $t0, $t0, $s2

sw $t0, 200($s4)

j Exit

else: addi $s3, $s3, (0 / 10 / 50 / 200 / $s1 / $t0)

lw $t0, 200($s4)

add $t0, 200($s4)

add $t0, $t0, ($s0 / $s1 / $s2 / $s3 / $s4 / $t0)

(beq / bne / j / add / addi / sll / lw / sw) $t0, 200($s4)

Exit:

b) Consider the following fragment of C code:

while (A[i] == 0) {

       A[i] = A[i] + 10;

       i += 1;

}

Assume that variable i is assigned to $s0 and the base address for array A is in $s1. A is an array of words. Registers $t0 and $t1 are used for storing results temporarily.

Loop: sll $t0, $s0, (0 / 1 / 2 / 4 / 10)

add $t0, $t0, $s1

lw $t1, 0( ($s0 / $s1 / $t0 / $t1 / $zero) )

bne $t1, $zero, (Loop / Exit)

addi $t1, ($s0 / $s1 / $t0 / $t1 / $zero), 10

sw $t1, 0($t0)

addi ($s0 / $s1 / $t0 / $t1 / $zero), $s0, 1

j Loop

Exit;

Solutions

Expert Solution

The answer for the above mentioned question is explained below ::

Explanation is as follows ::


Related Solutions

Provide the instruction type, assembly language instruction, and binary representation of the instruction described by the...
Provide the instruction type, assembly language instruction, and binary representation of the instruction described by the following LEGv8 fields: op = 0x458, Rm = 14, Rn = 16, Rd = 18, shamt = 0
1) Provide the type and assembly language instruction for the following binary value: 0000 0010 0001...
1) Provide the type and assembly language instruction for the following binary value: 0000 0010 0001 0000 1000 0000 0010 0000 (two) 2) Provide the type, assembly language instruction, and binary representation of instruction described by the following MIPS fields: op=0, rs=3, rt=2, rd=3, shamt=0, funct=34 3)For the following C statement, write a minimal sequence of MIPS assembly instructions that does the identical operation. Assume $t1 = A, $t2 = B, and $s1 is the base address of C. A...
Assembly Language Programming: a)If eax = 0FFFFFFFFH, and edx = 0FFFFFFFFH, then the instruction                            
Assembly Language Programming: a)If eax = 0FFFFFFFFH, and edx = 0FFFFFFFFH, then the instruction                              imul edx will leave the value ______________________________ in the edx register. b)If eax = 0D000000DH, and edx = 50000005H, then the instruction                              idiv dl will leave the value ______________________________ in the eax register. c)If ax = 3BC4H, then the following instructions                              cmp ah, al jg   Label will / will not cause a jump to Label. d)If ax = 3BC4H, then...
Write a possible assembly language instruction or set of instructions to accomplish the following: a) Compare...
Write a possible assembly language instruction or set of instructions to accomplish the following: a) Compare the byte stored at the memory location pointed to by register R4 to the upper (higher) byte stored in register R5 b) Branch to instruction at label ‘ZERO’ if the lower byte of register R6 is zero c) Jump to the instruction at label ‘EVEN’ if the value in register R7 is an even number
Assume that the instruction pointer, EIP, initially contains 2010 and the assembly language representation of the...
Assume that the instruction pointer, EIP, initially contains 2010 and the assembly language representation of the instructions in memory starting at address 2010 is Instruction Address Instruction 20 CMP DL, 0xD2 21 JE 72 Before the instruction sequence is executed, the flags are CF=0, ZF=0 and SF=0 and the Registers have the values AL=0x0D, BL=0xA9 CL=0x5E andDL=0xCF. What is the value of the instruction pointer after the sequence executes?
Give six examples of memory addressing commands in Intel assembly language two of each(register-memory, register offset...
Give six examples of memory addressing commands in Intel assembly language two of each(register-memory, register offset with an index, and perhaps one other) and explain what they are doing. Why is there no Assembly command to move an item from one RAM location to another directly?
Question 1 Selecting the programming language is important Group of answer choices It allows a programmer...
Question 1 Selecting the programming language is important Group of answer choices It allows a programmer to pick their favorite language It identifies the best language as the best tool for solving a particular problem It enables only certain programmer to communicate None of these Question 2 High level languages include Group of answer choices Basic, Fortran, Cobol, Pascal, C HTML, XML Java, C++ All of these Question 3 A major ethical concern on the Internet Group of answer choices...
Write in ARM assembly language the following operations without using multiplication instruction: a) A * 17...
Write in ARM assembly language the following operations without using multiplication instruction: a) A * 17 b). A * 23
What is the Opcode? What is the Operand? What is the value in Register 5 after the instruction is executed?
What is the Opcode? What is the Operand? What is the value in Register 5 after the instruction is executed?
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT