INFO 1006 Computer Architecture –practice paper 2 main tasks: Number System Exercises Printing in binary or decimal Specifying numbers in hex Number & character representation in the SIM20 Getting keyboard input Use of the insert command Level 1: Basic Course Requirement Number System Exercises 1.1 Convert these decimal numbers into their required forms Octal Binary Hexadecimal 22 751 1453 Tips: In compare to the decimal system which has column headings that go up multiplying by ten each time (1, 10, 100, 1000 and so on) 1.2 1.3 Marks 4.5 Binary system has column headings that go up multiplying by two each time (1, 2, 4, 8, 16 and so on). See the figure of "counting up in Binary" at the end of the paper for more detail. Octal system has column headings that go up multiplying by eight each time (1, 8, 64, and so on…). See the figure of "counting up in Octal " at the end of the paper for more detail. Hexadecimal system has column headings that go up multiplying by sixteen each time (1, 16, 256, and so on…). In order to store the digits from 0 to 15, six alphabets were introduced to cover the range from ten to fifteen: A (=10), B (=11), C (=12), D (=13), E (=14), F (=15). See the figure of "counting up in Hexadecimal" at the end of the paper for more detail. Convert these octal numbers into their required forms Decimal Binary Hexadecimal 73 3733 Convert these hexadecimal numbers into their required forms 3 1.5 Decimal 6A EF 6DA Designed by Lisha (Feb-08) - Part of the information was picked from the course notes Page 1 1.4 1.5 Convert this binary number into their required forms Octal Hexadecimal 11011101010110101011 1111000001 Find the two's complement of the following binary numbers, and then add the binary number 01010000 to each of the two's complement numbers that you worked out 2 2 Binary numbers The two's complement + 01010000 00110101 01000000 Tips: you should have 00011011 and 00010000 as your answers. Check your results by converting all the numbers from binary to decimal and working it out again in decimal. 1.6 Work out the following additions for three bit binary numbers in two's complement. In each case, determine whether or not overflow has occurred: Result 1.7 2 Overflow (Yes / No) 10011100 + 00100011 11001010 + 10001000 Convert the following numbers into floating point format: 37900194000 0.234 2344 0.0000128394 Printing in binary or decimal 1.8 Get ready: Compile and run the example program when CECIL is loaded 2 Marks 3 Printing in binary: Change the program title, (for example: printing in binary), the author, and the date, add your comments Change "print" to "printb" to print the answer in binary Compile and run your program You should have an answer of "0000010111" which is "23" in binary. Save your program 1.9 Printing in hexadecimal: Change the program title, (for example: printing in hexadecimal), the author, and the date, add your comments Add a $ in front of 12 (the value of data1) and 11 (the value of data2) Compile and run your program You should have an answer of "0000100011" which is "35" in binary. Save your program Designed by Lisha (Feb-08) - Part of the information was picked from the course notes 4 Page 2 Number & character representation in the SIM20 1.10 Run CECIL, enter header and comments to your preference. Enter code: .start load print printb printch stop ; ;--- now the data follows--; .data insert ; ;---end of source code-- Up to 10 marks 4 data 65 compile and run your program observe the output o hints: you should have “650001000001A” as your answer, this is because print prints numerical values, printb prints in binary, printch prints in ASCII format. 1.11 Load and printch “cr” and “lf”, in the data section insert value 13 for “cr” and 10 for “lf” every time before you print the value out in another format observe the output o hints: you should have the output of 65, 0001000001, and A in three separated lines. This is because CR moves to the start of the line and LF moves vertically down a line, so, using two of them together, you can achieve a new line. Save your program You are encouraged to have free experiments with other ASCII codes that control the screen layout. Getting keyboard input 1.12 Use “getkey” to get a character from the keyboard Enter “getkey”, -- place it after the “.start” .start 4 Marks 4 getkey Print the keyboard input in three different ways - numerical values, binary, and ASCII format. printch printb print Compile and run your program. o Hints: this code will take a keyboard input character and display the out put of three formats all together in one line Designed by Lisha (Feb-08) - Part of the information was picked from the course notes Page 3 Use of the insert command in CECIL 1.13 Enter header, comments and the code below: .start load mesg1 printch load mesg2 printch stop ; ;--- now the data follows--; .mesg1 insert "H" .mesg2 insert "I" ; ;---end of source code--- Marks 4 Compile and run the program You should have a message of "HI" as your out put, explain it briefly. o hints: CECIL provides a way of giving it the letter, and it converts it to ASCII, so that you don't need to remember the ASCII codes or look them up all the time. Total marks: 40 Level 2: Further Development Number & character representation in the SIM20 Up to 5 marks 2.1 Write yourself a program that loads a number into the A-register and then prints 10 it out in the three different ways. Getting keyboard input Up to 5 marks 2.2 Write a program that gets a number keypress from the keyboard and then display 10 it as that number Use of the insert command in CECIL Up to 5 marks 2.3 Write a program to print a short message out on the SIM20 screen. 10 Total marks: 30 Designed by Lisha (Feb-08) - Part of the information was picked from the course notes Page 4 Level 3: Challenge for experienced students Number System Exercises Marks 3.1 Magic Square: Using the nine hexadecimal numbers from A to 12, fill in the 10 following magic square so that each row, column and diagonal adds up to the same amount. hints: Each row, column and diagonal should add up to 2A; Try and work out which number should go in the centre square 3.2 Subsets: A set of things - e.g. the days of the week, {Monday, Tuesday, 10 Wednesday, Thursday, Friday, Saturday, Sunday} - can have a number of subsets - e.g. the weekend, {Saturday, Sunday}. Work out a formula for the number of subsets that a particular set can have. hints: Think in terms of binary numbers Printing in binary or decimal Marks 3.3 Write a program to print a short message out on the SIM20 screen, and take a 10 key board input character as an answer, and prints it out in three different formats, each of them display in a new line. Total marks: 30 Here are the programs, tables that mentioned in this practice paper, you can also find them from the course web site. Column Heading 128 64 1 1 1 1 1 1 32 1 1 1 16 8 4 1 1 ------ etc ----1 1 1 1 1 1 1 1 1 2 1 1 0 0 1 0 1 0 1 0 1 Value 0 1 2 3 4 5 0 1 1 1 0 1 253 254 255 Figure 1: Counting up in Binary Designed by Lisha (Feb-08) - Part of the information was picked from the course notes Page 5 Column Heading 16 1 Value 0 0 0 0 1 1 0 2 2 ------ etc --------0 A 10 0 B 11 0 C 12 0 D 13 0 E 14 0 F 15 1 0 16 Figure 2: Counting up in Hexadecimal Column Heading 64 0 0 0 0 0 1 3 8 1 Value 0 0 0 0 1 1 ------ etc --------1 0 8 1 1 9 ------ etc --------7 7 63 0 0 64 ------ etc --------7 7 255 Figure 3: Counting up in Octal Designed by Lisha (Feb-08) - Part of the information was picked from the course notes Page 6