50 likes | 198 Views
COMPSCI 210 Semester 1 - 2014. Tutorial 9 – Assignment 3. How to approach Assignment3. ( i ) read an instruction from the file ( ii) check the operation of the instruction ( iii) convert the operation to opcode and fill the corresponding bits in the instruction
E N D
COMPSCI 210Semester 1 - 2014 Tutorial 9 – Assignment 3
How to approach Assignment3 (i) read an instruction from the file (ii) check the operation of the instruction (iii) convert the operation to opcode and fill the corresponding bits in the instruction (iv) find out each of the operands(v) convert each of the operands to a binary number and fill the corresponding bits in the instruction (vi) display the instruction as a hexadecimal number
Exercise 9.1Ex9-1.c • Assume that there is a mapping table that maps the following letters to a 4-bit binary number, a is 0000, b is 0001, c is 0010, d is 0011, e is 0100, f is 0101, g is 0110, and h is 0111. For a given string consisting less than 9 letters, convert the string to a number and print out the string as an 8-digit hexadecimal number. For example, for string "bc", the number should be 00010010 (the first 4 bits are the number for b and the last 4 bits are the number for c, there should be some leading 0s if you represent it as a 32-bit number). The output should be 00000012.