=================================================== Notes and answers for Lab 08 (computer math, MARIE) =================================================== - Ian! D. Allen - idallen@idallen.ca - www.idallen.com Not all questions will be marked - check all your answers against this answer sheet: References: ECOA2e Section 3.2.1-3.2.4, 4.1-4.6, 4.8.1-4.9.1, 4.9.3, 4.10, 4.11.1 and associated Chapter Slides Class Notes under http://teaching.idallen.com/cst8214/07f/ bit_operations.txt text_errata.txt 1.What happens to the value of a binary number if you "shift" the bits to the left two places by adding two zeros after the rightmost binary digit, e.g. 11001 --> 1100100 [multiply by the base (2) twice = by four] 2.What happens to the value of an octal number if you "shift" the number to the left one place by adding one zero after the rightmost octal digit, e.g. 0377 --> 03770 [multiply by the base (8) once] 3.What happens to the value of a hexadecimal number if you "shift" the number to the left one place by adding one zero after the rightmost hex digit, e.g. 0xABC --> 0xABC0 [multiply by the base (16) once] 4.False - decimal 1234.0 x 10**37 fits in IEEE 754 single-precision floating-point. [1.234 x 10**40 does not fit!] 5.True - decimal 0.00001 x 10**40 fits in IEEE 754 single-precision floating-point. [ 1.0 x 10**35 fits!] 6.Circle the values that fit in a 32-bit two's complement integer with no loss of range or precision: [they all fit between -2**31 and +2**31-1] 7.Circle the values that fit in IEEE 754 single-precision floating-point with no loss of range or precision: [ only 2**30 and (2**30 + 2**29) fit without losing precision ] 8.Express in hexadecimal the value stored in memory by each of the following C bitwise expressions: char x = ~0x1; [ 0xFE (8 bits flip) ] char x = ~0x10; [ 0xEF ] char x = ~0 & 0xAA; [ 0xAA ] int x = ~0x1; [ 0xFFFFFFFE (32 bits flip) ] int x = ~0x10; [ 0xFFFFFFEF ] int x = ~0 & 0xAA; [ 0x000000AA ] char x = 0x11 | 0xAA; [ 0xBB ] 9.Give (hex) a bit mask that will mask off (zero) everything except a MARIE opcode: [ 0xF000 ] 10.Give (hex) a bit mask that will mask off (zero) everything except a MARIE address: [ 0x0FFF ] 11.Give a C language expression that will turn an ASCII Control character into the corresponding ASCII lower-case letter: [ char lower = ctrlch | 0x60 ] 12.How many address bits do you need to address byte-addressable 2Mx32 memory? [ see 3a p.237 and p.764 ] 13.How many address bits do you need to address word-addressable 2Mx32 memory? [ see 3b p.237 and p.764 ] 14.How many address bits do you need to address byte-addressable 4Mx16 memory? [ 4Mx16 = 2**2 * 2**20 * 2**1 bytes --> 23 address lines ] 15.How many address bits do you need to address word-addressable 4Mx16 memory? [ 4Mx16 = 2**2 * 2**20 words --> 22 address lines ] 16.Question 8, p.238: a) [8] b) [16] c) [2**16] d) [(2**24)-1] 17.Question 9, p.238: a) [see 9a p.238 and p.764] b) [see 9b p.238 and p.764] c) [ 2**18 words with addresses 0 through (2**18)-1 ] 18.Memorize the names and functions of the seven MARIE registers on p.191. Write the full names of the registers here: [ see text ] 19.True - unlike MARIE, modern computers have multiple general-purpose registers. (p.192) 20.True - unlike MARIE, the ISAs of modern computers have hundreds of instructions. (p.193) 21.Memorize the meanings of the nine basic MARIE instructions in Table 4.2. Reproduce that table here: [ see text ] 22.Define an instruction "mnemonic" (p.195): [the name of the instruction] 23.Another name for "binary instructions" is (p.195): [machine code] 24.The mnemonics that correspond to machine code are referred to as: [assembly language] 25.True - every assembly language instruction corresponds to exactly one machine instruction. 26.The name of the program that converts mnemonic assembly language to its binary equivalent machine code is (p.195, also Section 4.11): [assembler] 27.Give the hex for "Skip if AC less than zero": [ 0x8000 ] 28.Give the RTL for "Add X": [ MAR<--X, MBR<--M[MAR], AC<--AC+MBR ] 29.Give the RTL for "Jump X": [ PC<--X ] 30.Reproduce here the one-line descriptions (no RTN) of the revised instruction processing trio of operations from revised Section 4.9.1 (see the revised version in the Class Notes, file text_errata.txt): 1. [ fetch from memory (at location in PC), the instruction into the IR ] 2. [ increment PC by length of instruction ] 3. [ execute instruction from IR ] 31.Suppose the program in Table 4.3 started at hex address zero. Give the seven 16-bit hex values for the contents of memory: [ only instructions that contain an address have to be changed (relocated): 1004, 3005, 2006, 7000, 0023, FFE9, 0000 ] 32.An assembler reads a source file and produces as output (p.206): [ object code; an object file ]