This are some questions in computer organization.using MARS.can some one help me
ID: 638522 • Letter: T
Question
This are some questions in computer organization.using MARS.can some one help me to answer it?thank you
#Name : first_name last_name
.data
#Question 1: What is the machine code (in hexadecimal) of these instructions?
#Replace MACHINECODE1 with the machine code of your first instruction.
#Replace MACHINECODE2 with the machine code of your second instruction.
machine_code_1: .asciiz "MACHINECODE1"
machine_code_2: .asciiz "MACHINECODE2"
#Question 2: What instruction format are these instructions (R, I, or J)?
#Replace with your answer for the instruction format (R, I, J).
instruction_format: .asciiz ""
#Question 3: What are the values (in hexadecimal) of the immediate field in each instructions?
#Replace IMMEDIATEFIELD1 with the immediate field for the first instruction.
#Replace IMMEDIATEFIELD2 with the immediate field for the first instruction.
immediate_field_1: .asciiz "IMMEDIATEFIELD1"
immediate_field_2: .asciiz "IMMEDIATEFIELD2"
.text
#============================================================
#Place here your instructions to put 0xFACEBEEF into $t0.
#============================================================
#============================================================
#DO NOT MODIFY *ANYTHING* BELOW THIS LINE
#============================================================
#The following code uses system calls (syscalls)
#to print out the result of your code and your answers to the questions.
#Just to see if it worked, we'll print out $t0.
addi $v0, $zero, 4
la $a0, result_str
syscall
add $a0, $zero, $t0 #Copy $t0 into $a0 (required to print it)
addi $v0, $zero, 34
syscall
#Set $v0 to 4 for the print string syscall.
#From here on, we only print strings.
addi $v0, $zero, 4
la $a0, blank_line_str
syscall
la $a0, code_str
syscall
la $a0, hex_prefix_str
syscall
la $a0, machine_code_1
syscall
la $a0, blank_line_str
syscall
la $a0, hex_prefix_str
syscall
la $a0, machine_code_2
syscall
la $a0, blank_line_str
syscall
la $a0, format_str
syscall
la $a0, instruction_format
syscall
la $a0, blank_line_str
syscall
la $a0, immediate_str
syscall
la $a0, hex_prefix_str
syscall
la $a0, immediate_field_1
syscall
la $a0, blank_line_str
syscall
la $a0, hex_prefix_str
syscall
la $a0, immediate_field_2
syscall
la $a0, blank_line_str
syscall
.data
result_str: .asciiz "$t0 contains: "
code_str: .asciiz "The machine code (in hexadecimal) of these instructions are: "
hex_prefix_str: .asciiz "0x"
format_str: .asciiz "The instruction format of these instructions is: "
immediate_str: .asciiz "The immediate field of each instruction is: "
blank_line_str: .asciiz " "
Explanation / Answer
Part 2: Memory
.data
x: .half 15
y: .half 6
z: .half 0
.text
la $t0, x #Address of x is now in $t0
lh $s0, 0($t0) #Value of x is in $s0
lh $s1, 2($t0) #Value of y is in $s1
#compute z #z = x + y
add $s2, $s0, $s1
sh $s2, 4($t0) #Store z's new value to z's address
#This will overwrite the old value
sh $s2, 2($t0) #Store z's new value to y's address
sh $s2, 0($t0) #Store z's new value to x's address
.data
prompt1: .asciiz "What is the first value? "
prompt2: .asciiz "What is the second value? "
result_part_1: .asciiz "The difference of "
and_str: .asciiz " and "
is_str: .asciiz " is "
.text
#print "What is the first value?"
la $a0, prompt1
li $v0, 4
syscall
li $v0, 5 #Read integer syscall
syscall
#Now, the first number is in $v0.
#Copy it $v0's value to $s0 for safe keeping.
move $s0, $v0
#print "What is the second value?"
la $a0, prompt2
li $v0, 4
syscall
li $v0, 5 #Read integer syscall
syscall
#Now, the second number is in $v0.
#Copy it $v0's value to $s1 for safe keeping.
move $s1, $v0
#print "The difference of..."
la $a0, result_part_1
li $v0, 4
syscall
#Print out the first number.
move $a0, $s0
li $v0, 1
syscall
#print " and "
la $a0, and_str
li $v0, 4
syscall
#print out the first number.
move $a0, $s1
li $v0, 1
syscall #print " is "
la $a0, is_str
li $v0, 4
syscall
#Subtract $s1 from $s0 and put the result in $a0.
sub $a0, $s0, $s1
li $v0, 1
syscall
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.