Assembly

Status
Not open for further replies.

torok

Ars Tribunus Militum
2,000
Okay, I'm reading over last year's final, and there is one section that I just can't seem to figure out:

code:<HR>
Code:
         .data
X:       .word      0xf8
Y:       .word      0x8ca47<P>la       $si,X
lb       $t0,3($s1)<P>What's in $t0?
Answer: -8 or 0xfffffff8

Now, I don't see how she got that answer. When I write out the addresses in full binary I get:
X: 0000 0000 0000 0000 1111 1000
Y: 0000 1000 1100 1010 0100 0111

It's seems to me if you took a byte from 3 off of X you would get this portion:
000[0 0000 000]0 0000 1111 1000

but somehow she get's -8? There are not even that many ones in a row anywhere? Where is she getting that from? Thanks.
 

YakDaGringo

Ars Tribunus Militum
1,739
Yea, I was just trying to figure that out. la and lb? What crappy names for instructions. :p

[Edit] I'll take a shot: it's not a three bit offset. It's a three byte offset.

And why storing into $si and reading from $s1? You're sure this is a big-endian machine?

[Edit] OK: it could work if a word is 32 bits (four bytes), so it's written out:

X: 0000 0000 0000 0000 0000 0000 1111 1000

So the byte at three byte offset X would be

0000 0000 0000 0000 0000 0000 [1111 1000]

Right?

[Edit] clarity/consistency

[This message was edited by YakDaGringo on December 05, 2001 at 01:09.]
 

torok

Ars Tribunus Militum
2,000
Originally posted by YakDaGringo:
Yea, I was just trying to figure that out. la and lb? What crappy names for instructions. :p

[Edit] I'll take a shot: it's not a three bit offset. It's a three byte offset, and you've added an additional byte of zeros at the beginning for some reason I can't discern.

And why storing into $si and reading from $s1? You're sure this is a big-endian machine?

[Edit] OK: it could work if a word is 32 bits (four bytes), so it's written out:

X: 0000 0000 0000 0000 0000 0000 1111 1000

So the byte at three byte offset X would be

0000 0000 0000 0000 0000 0000 [1111 1000]

Right?

[This message was edited by YakDaGringo on December 05, 2001 at 00:56.]

Oh shit! You're right! Thank you so much. I had the wrong size for a word. :rolleyes:
 

YakDaGringo

Ars Tribunus Militum
1,739
Note tribus: Comp Sci 237; Computer Architecture. My prof is a sadist. Too bad I don't learn; I'm taking a tutorial from him next semester. :eek:

We're writing for a hypothetical machine, (based on Tannenbaum's MIC-1) so thankfully/unfortunately I only get one ALU, 30 scratchpad registers, and a pretty simple instruction set (except for pshreg and popreg, which are fsking HELL to implement; 16-bit mask for d0-d7 and a0-a7, each bit corresponds to a register :rolleyes: ). Anyway- it's pretty intense. We compete against each other, and our implementation is plotted on a graph with microinstructions/macroinstruction on the Y axis and the size of our control store on the X axis. He draws three lines (picture 1/x): A, B, and C, and if you're below the line, that's your grade. He moves the lines further down every year, and this year he halved the maximum size of the control store to 512 microinstructions. So needless to say, there are some stretches I've spent more time in the lab than in the dorm. Including sleep.

I love it, though. :p I wish I could ignore my other classes just for this week...
 
Status
Not open for further replies.