My professor taught us the bare basics and gives us questions on our homework that we essentially have to teach ourselves have to do. Any help would be appreciated! (use this for MIPS reference : http://www.mrc.uidaho.edu/mrc/people...al/MIPSir.html)
Here goes:

1. Write the binary representation of the smallest integer number that can be represented in 16-bit two's complement machine.

(I know that means 16 0's and 1's, but I do not know how to determine the smallest. Do I need to write it normally in binary and then convert or what?)

2. Write the machine instruction code (in hex) of the foloowing assembly code:

lw $t0, 0X46($10)
add $t2, $t0, $0

(I converted it into binary and got:
100011 01010 01000 00000 00001 01110
100000 01000 01010 00000 00000 00000
but that's totally wrong)

3. What does the following MIPS code do?

li $v0, 0
li $t1, 0
li $t2, 0

loop:
beq $t2, 6, endloop
lb $ $v1, AA($t1)
addu $v0, $v0, $v1
addi $t2, $t2, 1
addi $t1, $t1, 1
j loop

endloop:
....

.data
AA: .byte 8, 15, -3, 4, 12, 2, 9


(I put that it adds up the values in array 'AA' and stores the result in $v0 and got 5/7 points, but I do not know what else it could be doing)

4. Given the memory locations and addresses, fill in the blanks to place the word at 0X00405008 into $t1.

Memory Addresses
00000010 00405010
0000000C 0040500C
00000008 00405008
00000004 00405004
00000000 00405000

lui $s1, 0X____________
ori $s1, $s1, 0X___________
lw $t1, 0X________($s1)

(I don't know how to do this one at all)

Are you in Taha's class at UGA?

yes. Would you happen to know the pages in the book that would help?

1)look here http://en.wikipedia.org/wiki/Two's_complement
2) i have no idea
3) you have the right idea about adding in AA, but remember the loop. figure out what what its doing and when it's exiting
4) this one is confusing. he didn't say how to do it in class so i'm going to argue with him tomorrow. but there's only 4 numbers in each slot. you need one address and then another for the first two spaces. and the last space is the offset to get from the first to the last

Thanks! Yeah I didn't think he had ever mentioned how to do that last one

for 3 is it that the program just exits and that the system exit call must be stored in $v0 erasing whatever had been stored?

Hmm... Interesting there... Looks challenging for me to find the solution. Haven't done MIPS for 3+ years... The memory allocation is somewhat confusing but not too difficult to learn. I have already forgotten all of them though. :(

#2 - If you use SPIM, you should see all the memory allocation in HEX and should be able to answer this question.

#3
li $v0, 0
li $t1, 0
li $t2, 0

loop:
beq $t2, 6, endloop <-- branch to endloop if equal to 6
lb $ $v1, AA($t1) <-- load byte of the value in AA to $v1
addu $v0, $v0, $v1 <-- add unsigned value and store to $v0
addi $t2, $t2, 1 <-- loop counter (not really make sense to use this one)
addi $t1, $t1, 1 <-- next slot in AA (could only use this one in loop checking)
j loop

endloop:

As a result, you are adding unsigned values, not only adding value of AA.

#4 - here is my guess...
Memory Addresses
00000010 00405010
0000000C 0040500C
00000008 00405008
00000004 00405004
00000000 00405000

lui $s1, 0X____ <-- load the starting offset
ori $s1, $s1, 0X__ <-- compute the offset
lw $t1, 0X__($s1) <-- load 4 bytes to $t1 using the offset (look at Q2)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.