[Solved] CMPEN 331 Computer Organization and Design Lab 2

$25

File Name: CMPEN_331__Computer_Organization_and_Design_Lab_2.zip
File Size: 461.58 KB

SKU: [Solved] CMPEN 331 – Computer Organization and Design Lab 2 Category: Tag:
5/5 - (1 vote)

You should copy-and-paste the file lab2.txt into the MARS editor, and then save the file as your own, for editing. Spend some time trying to seewhat it does.The parts that need to be changed in main are between the comment lines Your part starts here and Your part ends here. You should also add morelines to the register assignment table, to describe what you did. Additional comments will probably be helpful. There are also two character stringsthat need to be changed, to put your names in the output.Here are the Mars Messages and Run I/O panels, after assembling and running the starter program.Assemble: assembling //lab2.asmAssemble: operation completed successfully.Go: running lab2.asmGo: execution completed successfully.CMPEN 331 Lab 2Students name0 0x00000000 0x00000003 00000000000000000000000000000000 000000000000000000000000000000111 0x00000024 0x00000003 00000000000000000000000000100100 000000000000000000000000000000112 0x0000007e 0x00000003 00000000000000000000000001111110 000000000000000000000000000000113 0x0000007f 0x00000003 00000000000000000000000001111111 000000000000000000000000000000114 0x00000080 0x00000003 00000000000000000000000010000000 000000000000000000000000000000115 0x000000a2 0x00000003 00000000000000000000000010100010 000000000000000000000000000000116 0x00000627 0x00000003 00000000000000000000011000100111 000000000000000000000000000000117 0x000007ff 0x00000003 00000000000000000000011111111111 000000000000000000000000000000118 0x00000800 0x00000003 00000000000000000000100000000000 000000000000000000000000000000119 0x000020ac 0x00000003 00000000000000000010000010101100 0000000000000000000000000000001110 0x00002233 0x00000003 00000000000000000010001000110011 00000000000000000000000000000011

11 0x0000ffff 0x00000003 00000000000000001111111111111111 0000000000000000000000000000001112 0x00010000 0x00000003 00000000000000010000000000000000 0000000000000000000000000000001113 0x00010348 0x00000003 00000000000000010000001101001000 0000000000000000000000000000001114 0x00022e13 0x00000003 00000000000000100010111000010011 0000000000000000000000000000001115 0x0010ffff 0x00000003 00000000000100001111111111111111 0000000000000000000000000000001116 0x89abcdef 0x00000003 10001001101010111100110111101111 00000000000000000000000000000011All done! program is finished running Your output should be the same, except for the name, and the value of n that is printed (its a constant 3 in the starter version).The assignment is based on a short function used in the implementation of the UTF-8 data format. Here are some descriptions of UTF-8: http://en.wikipedia.org/wiki/UTF-8 The function in question is write_utf8() in the Sample Code section. There are also some examples of the data formats in the Description section. http://www.ietf.org/rfc/rfc3629.txt This is the official definition of UTF-8, from which we will take one diagram. http://www.cl.cam.ac.uk/~mgk25/unicode.html UTF-8 and Unicode FAQ for Unix/Linux The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!), by JoelSpolsky Useful background information, exactly as the title says.The idea behind UTF-8 is to augment a character code with some additional bits to protect against certain kinds of communication failures. Here isthe standard diagram:Char. number range | UTF-8 octet sequence(hexadecimal) | (binary)-+-0000 0000 0000 007F | 0xxxxxxx0000 0080 0000 07FF | 110xxxxx 10xxxxxx0000 0800 0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx0001 0000 0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxxThe term octet means 8 bits, which everyone now thinks of as one byte. There were once computers whose byte size was not 8 bits, but they areall gone now.

The basic if-then-else structure, from write_utf8(), isif (code_point < 0x80) { case 1} else if (code_point <= 0x7FF) { case 2} else if (code_point <= 0xFFFF) { case 3} else if (code_point <= 0x10FFFF) { case 4} else { case 5}In the starter version provided, we used the variable j instead of code_point. Each case should compute n from j.Its going to be a lot easier if you sketch the solution in C, and then rewrite it into MIPS assembler, inserting the C version as a comment. Start withthe if-then-else structure, and test that with some bogus values for n. Then, write each of the five cases separately; two of these are trivial, and theother three have a lot of features in common.The MIPS assembly code is slightly easier to write if all the tests are < instead of a mixture of < and <= . Also, treat the registers as if they containunsigned integers (when using a numeric instruction) or simple bit strings (when using logical and shift instructions).In case 1, j fits in 7 bits, and it is expanded to 8 bits with a leading 0 bit, which yields the same value. In case 5, its an error, so n is -1 or0xFFFFFFFF; thats not the proper treatment of errors according to UTF-8, but its certainly easier.The following comments describe how the bits of j are to be rearranged to form the bits of n.

if (j < 0x80) {// j fits in 7 bits, expand to 8 bits// n = j} else if (j <= 0x7FF) {// j fits in 11 bits, expand to 16 bits// b = low 6 bits of j// a = next 5 bits of j// n = 110 a 10 b// 5 6 bits in// j = aaaaa bbbbbb// 3 5 2 6 bits out// n = 110 aaaaa 10 bbbbbb} else if (j <= 0xFFFF) {// j fits in 16 bits, expand to 24 bits// c = low 6 bits of j// b = next 6 bits of j// a = next 4 bits of j// n = 1110 a 10 b 10 c// 4 6 6 bits in// j = aaaa bbbbbb cccccc// 4 4 2 6 2 6 bits out// n = 1110 aaaa 10 bbbbbb 10 cccccc} else if (j <= 0x10FFFF) {// j fits in 21 bits, expand to 32 bits// d = low 6 bits of j// c = next 6 bits of j// b = next 6 bits of j// a = next 3 bits of j// n = 11110 a 10 b 10 c 10 d// 3 6 6 6 bits in// j = aaa bbbbbb cccccc dddddd// 5 3 2 6 2 6 2 6 bits out// n = 11110 aaa 10 bbbbbb 10 cccccc 10 dddddd} else {// j is outside the UTF-8 range of character codes// n = 0xFFFFFFFF}Here is the output from a correct solution, using MARS. The name strings have not been changed be sure you do that

CMPEN 331 Lab 2Students name0 0x00000000 0x00000000 00000000000000000000000000000000 000000000000000000000000000000001 0x00000024 0x00000024 00000000000000000000000000100100 000000000000000000000000001001002 0x0000007e 0x0000007e 00000000000000000000000001111110 000000000000000000000000011111103 0x0000007f 0x0000007f 00000000000000000000000001111111 000000000000000000000000011111114 0x00000080 0x0000c280 00000000000000000000000010000000 000000000000000011000010100000005 0x000000a2 0x0000c2a2 00000000000000000000000010100010 000000000000000011000010101000106 0x00000627 0x0000d8a7 00000000000000000000011000100111 000000000000000011011000101001117 0x000007ff 0x0000dfbf 00000000000000000000011111111111 000000000000000011011111101111118 0x00000800 0x00e0a080 00000000000000000000100000000000 000000001110000010100000100000009 0x000020ac 0x00e282ac 00000000000000000010000010101100 0000000011100010100000101010110010 0x00002233 0x00e288b3 00000000000000000010001000110011 0000000011100010100010001011001111 0x0000ffff 0x00efbfbf 00000000000000001111111111111111 0000000011101111101111111011111112 0x00010000 0xf0908080 00000000000000010000000000000000 1111000010010000100000001000000013 0x00010348 0xf0908d88 00000000000000010000001101001000 1111000010010000100011011000100014 0x00022e13 0xf0a2b893 00000000000000100010111000010011 1111000010100010101110001001001115 0x0010ffff 0xf48fbfbf 00000000000100001111111111111111 1111010010001111101111111011111116 0x89abcdef 0xffffffff 10001001101010111100110111101111 11111111111111111111111111111111All done! program is finished running When your program is complete and you are satisfied it is right, or when you just ran out of time, put it in the ANGEL Dropbox for Lab 2. Use thefilename Lab2.asm. Your name should be in the file, and appear in the output.The programs will be tested using MARS, and the TA will actually look at the program. Its important for your program to be correct, and to bereadable. It should also be efficient, but an efficient wrong program is still wrong, and an unreadable program doesnt inspire confidence that youknow what you are doing.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CMPEN 331 Computer Organization and Design Lab 2
$25