CMPEN LAB

This topic uses the MARS MIPS vaunter. The appearance is to transcribe a loop in nock that converts hexadecimal collection into UTF-8 binary sequences. The details are as follows: You should copy-and-paste the polish lab2.txt [which is pasted under] into the MARS editor, and then obviate the polish as your own, for editing. Spend some interval perplexing to see what it does. The tonnage that demand to be newfangled in ocean are among the interpret lines Your segregate starts close and Your segregate ends close. You should so add further lines to the record assignment table, to draw what you did. Concomitant interprets conciliate probably be advantageous. Tclose are so two genius strings that demand to be newfangled, to put your names in the output. Here are the Mars Messages and Run I/O panels, succeeding assembling and vulgar the starter program: Assemble: assembling /.../lab2.asm Assemble: agency consummated successfully. Go: vulgar lab2.asm Go: deed consummated successfully. 0 0x00000000 0x00000003 00000000000000000000000000000000 00000000000000000000000000000011 1 0x00000024 0x00000003 00000000000000000000000000100100 00000000000000000000000000000011 2 0x0000007e 0x00000003 00000000000000000000000001111110 00000000000000000000000000000011 3 0x0000007f 0x00000003 00000000000000000000000001111111 00000000000000000000000000000011 4 0x00000080 0x00000003 00000000000000000000000010000000 00000000000000000000000000000011 5 0x000000a2 0x00000003 00000000000000000000000010100010 00000000000000000000000000000011 6 0x00000627 0x00000003 00000000000000000000011000100111 00000000000000000000000000000011 7 0x000007ff 0x00000003 00000000000000000000011111111111 00000000000000000000000000000011 8 0x00000800 0x00000003 00000000000000000000100000000000 00000000000000000000000000000011 9 0x000020ac 0x00000003 00000000000000000010000010101100 00000000000000000000000000000011 10 0x00002233 0x00000003 00000000000000000010001000110011 00000000000000000000000000000011 11 0x0000ffff 0x00000003 00000000000000001111111111111111 00000000000000000000000000000011 12 0x00010000 0x00000003 00000000000000010000000000000000 00000000000000000000000000000011 13 0x00010348 0x00000003 00000000000000010000001101001000 00000000000000000000000000000011 14 0x00022e13 0x00000003 00000000000000100010111000010011 00000000000000000000000000000011 15 0x0010ffff 0x00000003 00000000000100001111111111111111 00000000000000000000000000000011 16 0x89abcdef 0x00000003 10001001101010111100110111101111 00000000000000000000000000000011 All produced! -- program is high vulgar – The subject rearwards UTF-8 is to raise a genius edict after a while some concomitant bits to secure athwart indubitable kinds of despatch failures. Close is the banner diagram: The tokenal "octet" media "8 bits", which everyone now thinks of as one byte. Tclose were once scoldrs whose byte bigness was not 8 bits, but they are all bybygone now. In the starter account granted, we used the changeing j instead of edict_point. Each event should scold n from j. It's going to be a lot easier if you paint the breach in C, and then retranscribe it into MIPS assembler, inserting the C account as a interpret. Start after a while the if-then-else building, and criterion that after a while some erroneous appreciates for n. Then, transcribe each of the five events separately; two of these are useless, and the other three accept a lot of features in sordid. The MIPS nock edict is portioially easier to transcribe if all the criterions are < instead of a combination of < and <= . Also, write the records as if they comprise unsigned integers (when using a numeric advice) or primal bit strings (when using discussionative and change advices). In event 1, j fits in 7 bits, and it is large to 8 bits after a while a imported 0 bit, which yields the corresponding appreciate. In event 5, it's an deception, so n is -1 or 0xFFFFFFFF; that's not the equitable writement of deceptions according to UTF-8, but it's indubitablely easier. The subjoined interprets draw how the bits of j are to be rearranged to constitute the bits of n. Here is the output from a amend breach, using MARS: You are high when you are satisfied that your program performances and runs efficiently. BELOW IS THE BASE CODE REFERENCED AT THE BEGINNING (lab2.txt): # CMPEN 331, Lab 2 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # switch to the Grounds segment .data # global grounds is defined close # Don't pretermit the backslash-n (newline genius) Homework: .asciiz "CMPEN 331 Homeperformance 2\n" Name_1: .asciiz "First Person's name\n" Name_2: .asciiz "Second Person's name\n" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # switch to the Text segment .text # the program is defined close .globl ocean main: # Whose program is this? la $a0, Homework jal Print_string la $a0, Name_1 jal Print_string la $a0, Name_2 jal Print_string # int i, j = 2, n = 3; # for (i = 0; i <= 16; i++) # { # ... j = criterioncase[i] # ... number n from j # ... sculpture i, j and n # } # record assignments # $s0 i # $s1 j = criterioncase[i] # $s2 n # $t0 harangue of criterioncase[i] # $a0 discussion to Print_integer, Print_string, etc. # add to this record if you use any other records # initialization li $s1, 2 # j = 2 li $s2, 3 # n = 3 # for (i = 0; i <= 16; i++) li $s0, 0 # i = 0 la $t0, criterionevent # harangue of criterioncase[i] bgt $s0, 16, bottom top: lw $s1, 0($t0) # j = criterioncase[i] # number n from j # Your segregate starts close # Your segregate ends close # sculpture i, j and n move $a0, $s0 # i jal Print_integer la $a0, sp # space jal Print_string move $a0, $s1 # j jal Print_hex la $a0, sp # space jal Print_string move $a0, $s2 # n jal Print_hex la $a0, sp # space jal Print_string move $a0, $s1 # j jal Print_bin la $a0, sp # space jal Print_string move $a0, $s2 # n jal Print_bin la $a0, nl # newline jal Print_string # for (i = 0; i <= 16; i++) addi $s0, $s0, 1 # i++ addi $t0, $t0, 4 # harangue of criterioncase[i] ble $s0, 16, top # i <= 16 bottom: la $a0, produced # impression the end of the program jal Print_string jal Exit0 # end the program, omission repay standing # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - .data # global grounds is defined close sp: .asciiz " " # space nl: .asciiz "\n" # newline done: .asciiz "All produced!\n" testcase: # UTF-8 justice is one byte .order 0x0000 # nul # Basic Latin, 0000 - 007F .order 0x0024 # $ (dollar token) .order 0x007E # ~ (tilde) .order 0x007F # del # UTF-8 justice is two bytes .order 0x0080 # pad # Latin-1 Supplement, 0080 - 00FF .order 0x00A2 # cent token .order 0x0627 # Arabic epistle alef .order 0x07FF # unassigned # UTF-8 justice is three bytes .order 0x0800 .order 0x20AC # Euro token .order 0x2233 # anticlockwise contour sound token .order 0xFFFF # UTF-8 justice is lewd bytes .order 0x10000 .order 0x10348 # Hwair, see http://en.wikipedia.org/wiki/Hwair .order 0x22E13 # randomly-separated genius .order 0x10FFFF .order 0x89ABCDEF # randomly separated erroneous appreciate # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Wrapper functions about some of the method calls # See P&H COD, Fig. A.9.1, for the consummate record. .text .globl Print_integer Print_integer: # sculpture the integer in record $a0 (decimal) li $v0, 1 syscall jr $ra .globl Print_string Print_string: # sculpture the string whose starting harangue is in record $a0 li $v0, 4 syscall jr $ra .globl Exit Exit: # end the program, no patent repay standing li $v0, 10 syscall jr $ra # this advice is never executed .globl Exit0 Exit0: # end the program, omission repay standing li $a0, 0 # repay standing 0 li $v0, 17 syscall jr $ra # this advice is never executed .globl Exit2 Exit2: # end the program, after a while repay standing from record $a0 li $v0, 17 syscall jr $ra # this advice is never executed # The subjoined syscalls performance on MARS, but not on QtSPIM .globl Print_hex Print_hex: # sculpture the integer in record $a0 (hexadecimal) li $v0, 34 syscall jr $ra .globl Print_bin Print_bin: # sculpture the integer in record $a0 (binary) li $v0, 35 syscall jr $ra # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -