

































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


































































A character has been loaded into a register by using a lbu instruction. What does the register look like? A. The character is in the low-order byte. The three high-order bytes are zero. B. The character is in the low-order byte. The three high-order bytes are whatever they were just before the instruction. C. The character is in the high-order byte. The three low-order bytes are zero. D. The character is in the low-order byte. The three high-order bytes contain one-bits. Correct answer A. The character is in the low-order byte. The three high-order bytes are zero. A digital image is stored in a file. The pixels of the image represent a gray level of 0 to 255. What instruction are you likely to use in loading a register with the value of a pixel? A. lb B. lbu C. lh D. lhu Correct answer B. lbu A lw is to load register $5 from location 0x0040000C in memory. Register $10 contains 0x00400000. Write the assembly language instruction:
A. lw $10,0x0C($10) B. lw $10,0x0C($5) C. lw $5,0x0C($10) D. lw $5,0x0C(400000) Correct answer C. lw $5,0x0C($10) A main routine passes control to a subroutine subA. Which of the following is usually true? A. When subA is done it returns control to main a few statements after where it was called. B. When subA is done it returns control to the the start of main. C. When subA is done it returns control to the operating system. D. When subA is done the whole program is finished. Correct answer A. When subA is done it returns control to main a few statements after where it was called A. 00110110 B. 00110100 C. 10001101 D. 10000001 Correct answer A. 00110110
C. It grows toward the address in the stack pointer. D. It grows in whichever direction is available. Correct answer B. In grows downward toward lower addresses. Assemblers and compilers usually translate a source program into machine instructions contained in what type of file? Correct answer C. object module Assume that the stack pointer has already been set up and that the stack contains data. Which of the following code fragments POPS a word of data to register $t0? A. sw $t0,($sp) addu $sp,$sp, B. lw $t0,($sp) subu $sp,$sp, C. lw $t0,($sp) addu $sp,$sp, D. addu $sp,$sp, lw $t0,($sp) Correct answer C. lw $t0,($sp) addu $sp,$sp,
Assume that the stack pointer has already been set up. Which of the following code fragments pushes a word of data from register $t0? Correct answer D. subu $sp,$sp, sw $t0,($sp) D At what address does the SPIM simulator put the first machine instruction when it is running with the Bare Machine option turned ON? A. 0x B. 0x C. 0x D. 0xFFFFFFFF Correct answer B. 0x By software convention, the machine instructions of a program are put in a designated section of memory. What is this section called? A. Data segment. B. Stack segment. C. Program segment. D. Text segment. Correct answer D. Text segment.
Can the ori instruction put the two's complement representation of a negative integer into a register? A. No. B. Yes. Correct answer A. No. Do all machine instructions have the same parts? A. No. Different types of machine instructions are made of different fields. B. No. Each machine instruction is completely different from any other. C. Yes. All machine instructions have the same parts in the same order. D. Yes. All machine instructions have the same parts, but they might be in different orders. Correct answer A. No. Different types of machine instructions are made of different fields. Do all processor chips use the same machine language? Correct answer A. No. Machine language is an engineering decision that is unique to each processor family. Does a microprocessor need special instructions for input/output and for graphics? A. No. This is done by using ordinary load and store operations with special addresses that have been assigned to the devices.
B. No. This is done by loading a storing special registers within the microprocessor. C. Yes. Special I/O and graphics machine instructions are used, but these are not included in the definition of computing power. D. Yes. Special I/O and graphics machine instructions are used, and these are included in the definition of computing power. Correct answer A. No. This is done by using ordinary load and store operations with special addresses that have been assigned to the devices. Does the extended assembler translate assembly language into machine instructions not available to the basic assembler? A. No. Extended assembly language is just an alternate syntax used to specify the same machine instructions. B. No. The extended assembler uses many fewer of the actual machine instructions. C. Yes. The extended assembler outputs instructions for the extended part of the processor. D. Yes. The extended assembler is the only way to ask for floating-point operations. Correct answer A. No. Extended assembly language is just an alternate syntax used to specify the same machine instructions. Does the stack contain data that was declared in the .data section of a program? A. No. That goes in the data segment of memory. B. No. That goes in the text segment of memory. C. Yes. The stack contains all the data of the program.
ori $8,$0, bgez $8,target ori $9,$0, ori $9,$0, target: sll $0,$0,0 # arbitrary instruction Correct answer B. 1 Examine the following program fragment: addiu $3,$0,- slti $5,$3, What value is in $5 after both instructions exectute? (If your answer is incorrect, run the program with SPIM and examine the registers. SPIM does not "know" how the bit pattern got into $3, it's just a pattern and the slti instruction acts on it mechanically.) Correct answer A. 0 Examine the following program fragment: addiu $3,$0,- addiu $7,$0, ????? Pick the instruction to replace ????? that will set register $10 to one. Correct answer C. slt $10,$3,$ Examine the following program fragment:
addiu $3,$0,- slti $5,$3,- What value is in $5 after both instructions exectute? Correct answer B. 1 Examine the following program fragment: ori $3,$0, slti $5,$3, What value is in $5 after both instructions exectute? Correct answer B. 1 Examine the following program fragment: ori $5,$0,5 # initialize count ori $8,$0,0 # initialize accumulator test: bltz $5,done sll $0,$0, addu $8,$8,$5 # add count to accumulator addiu $5,$5,- j test sll $0,$0, done: sll $0,$0,
Examine the following program fragment: ori $8,$0, ori $9,$0, bltz $8,target sll $0,$0, ori $9,$0, target: sll $0,$0,0 # arbitrary instruction What value is found in $9 when control reaches target? Correct answer A. 0 Examine the following program fragment.
.text .... program statements ... .data value: .word 23 result: .word 97
Assuming that SPIM starts the data section at address 0x10000000, what address does symbolic address result represent? Correct answer A. 0x Examine the following program fragment. The program is to add $5 and $6 together only if they are not equal. ori $5,$0,8 # load $5 with 8 ori $6,$0,9 # load $6 with 9 ____ $5,$6,spot ____ $0,$0,0 # branch delay slot addu $8,$5,$6 # $8 = $5 + $ spot: Pick instructions to fill the blanks. Correct answer D. beq ; sll f you have two integers, each represented in 32 bits, how many bits might be needed to hold the product? A. 16 B. 32 C. 64 D. 128 Correct answer C. 64
.data array: .byte 12,23,45,12,-5, Which of the following pseudoinstructions loads register $s1 with the 45? Correct answer C. li $t0, lb $s1,array($t0) Here is a fragment of code. .data string: .asciiz "Hello Virtual World!" Which of the following pseudoinstructions loads register $s1 with the 'V'? Correct answer B. li $t0, lb $s1,string($t0) Here is a fragment of code. (Note the subtle change from the previous question.) .data array: .word 12,23,45,12,-5, Which of the following pseudoinstructions loads register $s1 with the 45? Correct answer B. li $t0, lw $s1,array($t0)
Here is a program that loads register $5 with a bit pattern. Complete the program so that register $4 receives the pattern in register $5 shifted left logical by three positions. ori $5, $0, 0x92AF # put a bit pattern into register $ sll ___, ___, ___ # shift left logical by three, put
A. sll $5, $3, $ B. sll 3, $5, $ C. sll 5, 3, 4 D. sll $4, $5, 3 Correct answer D. sll $4, $5, 3 Here is a schematic program loop. Address Instruction (details omitted) PC just after this instruction has executed (at the bottom of the cycle) ............... ........... 00450008 00450008 add 0045000C 0045000C store 00450010 00450010 jump 0x00450008 004500___ 00450014 no-op 004500___ What numbers go into the two blanks? Correct answer A. 14 08
How does SPIM display the data section of simulated main memory? A. One byte per address in columns. B. In groups of 4-byte words with the highest address on the right. C. In groups of 4-byte words with the lowest address on the right. D. This depends on the type of data in memory. Correct answer C. In groups of 4-byte words with the lowest address on the right. How is a character pointer typically moved from one character to the next? A. It is incremented by four with a addiu instruction. B. It is incremented by one with a add instruction. C. It is incremented by one with a addiu instruction. D. It is changed with a move instruction. Correct answer C. It is incremented by one with a addiu instruction. How is a null-terminated string arranged in memory? A. Characters are grouped four to a full word from right to left. Extra space at the end is filled with zeros. B. Characters are put in sequential order with a null byte after the last character. C. Characters are put in sequential order one per word with a word of null after the last character.
D. Characters are put in sequential order in memory. Space characters are replaced with null bytes. Correct answer B. Characters are put in sequential order with a null byte after the last character. How is an array of integers typically implemented? A. The integers of the array are put in sequential words of memory. A word of zeros follows the last integer. B. The integers of the array are put in sequential words of memory. Another word of memory contains the length of the array. C. The integers of the array are put in sequential bytes of memory. The last byte holds the length of the array. D. Each integer of the array is assigned to one of the general purpose registers. Correct answer B. The integers of the array are put in sequential words of memory. Another word of memory contains the length of the array. How is the li d,value translated by the extended assembler? A. It is always translated into the addiu basic instruction. B. It is always translated into the one basic instruction. C. How it is translated depends on the size and sign of the value. D. It is always translated into two basic instructions. Correct answer C. How it is translated depends on the size and sign of the value. How many bits are the operands of the ALU?