CPS 104 (Ramm) Page 1 of 4 28 September Fall Semester, 1994 OPEN BOOK Hour Test #1 NAME___________________ When possible, answer on the test sheets or on the back. Use additional sheets if needed. (10) A. This problem is to check your understanding of PDP 11 A ____ addressing. In each of the following cases, tell what will be the value found in register 1 when the instruction shown has (5) been executed. ALL VALUES ARE IN OCTAL. B ____ Make the following assumptions: (5) Register 3 contains 033333 . C ____ Location 200, also labeled X, contains 121212 . Each of the following MOV statements is "sitting at" (5) location 000140 . D ____ Assembler Machine Language Register 1 after execution (5) E ____ 1) MOV X,%1 016701 000034 ______________ (5) 2) MOV #X,%1 012701 000200 ______________ F ____ 3) MOV %3,%1 010301 ______________ (30) G ____ (Note that in the textbook, $ is used in place of # and R in place of %). (10) H ____ B. What in the Intel 8088 (PC) processor's address postbyte structure makes memory to memory operations impossible? (15) I ____ (10) J ____ C. Which of the following instructions are illegal on the MIPS (5) simulator? (Cross out the incorrect instructions.) K ____ sw $21, $17, $16 (5) L ____ move $2, $15 (10) bne again M ____ --------- add $22, $15, $33 lw $18, 28($29) sra $12, $12, 6 D. On an Intel 8088, assume that DS contains C300, SI contains 0520 (all in hex). What (20 bit) physical address is accessed by the following instruction? INC 3[SI] Circle the correct answer: 0C823 ? C3523 ? 000C3 ? Test #1 NAME ___________________ Page 2 of 4 E. On the Intel 8088 (IBM PC) why is the maximum size of a segment 64K bytes? F. Below is a table showing unsigned numbers in binary, octal, decimal, and hexadecimal. Fill in the equivalent decimal and hexadecimal values. Also give the parity (odd/even) of each of these numbers. Base Number Decimal Equivalent Hex Equivalent Parity binary 00011111 __________ ________ ___ octal 77 __________ ________ ___ decimal 2048 __2048____ ________ ___ hexadecimal FF __________ ___FF___ ___ G. Write a COMPLETE MIPS assembler program to go through a list of N numbers (stored as words in LIST) and print (display) each number twice. For example, if N contains a three and thus LIST contains three numbers (for example 3, 15, 7), then the output should be something like: 3 3 15 15 7 7 Note that this is not meant to be very useful, but rather checks your ability to write loops in assembler. You must use a loop and indexing to process this list. You must use the value in N to control how many iterations to perform. Include sample date, but the program must work for any reasonably sized value of N and the corresponding LIST. OMIT COMMENTS. H. Pages 44 thru 48 in your textbook deal with the Hamming code for error correction. What follows is the bit pattern for a 10 bit number for which a one bit error has been introduced. TELL WHICH BIT IS IN ERROR. The layout for the information and check bits are identical to that shown in figure 2-14 on page 48. The parity bits are identified below the numbers identifying the bit position. Note that before the error, parity bits were set to make the total parity for the bits being checked EVEN. bits: 0 1 1 0 0 0 1 0 0 0 0 1 1 0 position: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 parity bits: P1 P2 P4 P8 After correction, and ignoring the parity bits, what are the 10 data bits? (I.e. what is the data value in decimal) ___________? Test #1 NAME ___________________ Page 3 of 4 I. On the back of the previous page, trace the program shown below. It is intended to run on the hypothetical machine discussed in class (and used in HW #1) For this trace, all you need are columns for the LOCATION of the instruction just executed, the op code MNEMONIC of that instruction, and the contents of the ACCUMULATOR after the instruction was executed. MACHINE LANGUAGE ASSEMBLER LANGUAGE Location Instruction Label Mnemon. Address 200 11214 LOOP LOAD SUM 201 21215 OPER ADD LIST 202 12214 STORE SUM 203 11213 LOAD COUNT 204 22220 SUB STEP 205 12213 STORE COUNT 206 31219 CMP ZERO 207 42212 JE DONE 208 11201 LOAD OPER 209 21220 ADD STEP 210 12201 STORE OPER 211 41200 JMP LOOP 212 00000 DONE HALT 213 00003 COUNT DW 4 214 00000 SUM DW 0 215 00012 LIST DW 12 216 99985 DW -15 217 99993 DW -7 218 00010 DW 10 219 00000 ZERO DW 0 220 00001 STEP DW 2 END LOOP J. What does the following MIPS program fragment do to the bytes starting at the location (variable) labeled as STRING? Don't describe each instruction in detail. Instead give the program's overall function. (If you are uncertain of the origin of the 32 in the program, look at the ASCII table on page 72. Remember that decimal 32 is octal 40.) ... STRING .asciiz "the sum is" ... la $18, STRING again: lbu $10, 0($18) beq $10, $0, done sub $10, $10, 32 sb $10, 0($18) add $18, $18, 1 jmp again done: ... Above, what does the string (null terminated list of bytes) at STRING contain after this program fragment is executed? ______________________ Test #1 NAME ___________________ Page 4 of 4 K. Assume a disk has the storage capacity of 25.6 Million bytes. You also know that is has 200 cylinders and its track capacity is 32000 bytes per track. How many read/write heads (or recording surfaces) does it have? L. On the IBM System 360, with its one byte op code, how many different instructions could that design have supported? M. Assume we have a large disk file that contains only characters representing letter grades. The relative frequencies observed are shown below. Design a Huffman Code for these six characters that lets us represent the same file in a much compressed form. WRITE OUT A TABLE OF CODES GIVING EACH CHARACTER AND THE CORRESPONDING BINARY CODE. Digit(char): 'A' 'B' 'C' 'D' 'F' 'I' Frequency: 28 30 16 8 6 12