Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Assembly (http://www.programmingforums.org/forum20.html)
-   -   Mips/spim (http://www.programmingforums.org/showthread.php?t=9020)

programmingnoob Mar 24th, 2006 9:32 AM

Mips/spim
 
Address Content
------------------------
[0x00400000] 0x123e0203

^^If you're familiar with spim, or even mips ... you will know what i'm talkin about ...


I have a couple of questions:
what does that x in there mean?

and if I want to print out the content, then how do I do that?

like i could do sw 0(address) ... but it will give me value in decimal .. not in hex ... so will i have to convert decimal into hex just to print out the content?

thanks!

MBirchmeier Mar 24th, 2006 10:11 AM

Quote:

Originally Posted by programmingnoob
Address Content
------------------------
[0x00400000] 0x123e0203

^^If you're familiar with spim, or even mips ... you will know what i'm talkin about ...


I have a couple of questions:
what does that x in there mean?

and if I want to print out the content, then how do I do that?

like i could do sw 0(address) ... but it will give me value in decimal .. not in hex ... so will i have to convert decimal into hex just to print out the content?

thanks!

Isn't '0x' a prefix letting you know the data is in hex format rather than decimal?

As for printing I have no idea.

-MBirchmeier

programmingnoob Mar 24th, 2006 11:37 AM

Quote:

Originally Posted by MBirchmeier
Isn't '0x' a prefix letting you know the data is in hex format rather than decimal?

As for printing I have no idea.

-MBirchmeier

that's what i thought at first .. but then i saw some other things about it, and i got confused :-/

programmingnoob Mar 24th, 2006 12:10 PM

Quote:

Originally Posted by MBirchmeier
Isn't '0x' a prefix letting you know the data is in hex format rather than decimal?

As for printing I have no idea.

-MBirchmeier

you're right ... i dunno why i was getting confused about it

programmingnoob Mar 26th, 2006 12:45 AM

help?? please!!!!!

hbe02 Mar 26th, 2006 2:03 AM

[0x00400000] 0x123e0203
To start off, [0x00400000] is an adress value in memory of the instruction 0x123e0203(instruction you need to decode).
0x is the prefix for hexa presentation
now lets decode 0x123e0203
0001 0010 0011 1110 0000 0010 0000 0011
000100 10001 11110 0000001000000011
first 6 bits are the opcode giving->beq (branch if equal) which is an I format instruction.
we have two registers to compare 10001 -> $17 = $s1
11110 -> $30 = $fp

and 0000001000000011 is the immediate field corresponding to a label you need to branch to if $s1 == $fp.
this binary number is an offset from the current position address.
meaning the label should be [0x00400000] + 0000 0010 0000 0011 ( sign extended offcource)
the branch address should be [0x00400000] + 0x203 = [0x00400203]

programmingnoob Mar 26th, 2006 2:37 AM

Quote:

Originally Posted by hbe02
[0x00400000] 0x123e0203
To start off, [0x00400000] is an adress value in memory of the instruction 0x123e0203(instruction you need to decode).
0x is the prefix for hexa presentation
now lets decode 0x123e0203
0001 0010 0011 1110 0000 0010 0000 0011
000100 10001 11110 0000001000000011
first 6 bits are the opcode giving->beq (branch if equal) which is an I format instruction.
we have two registers to compare 10001 -> $17 = $s1
11110 -> $30 = $fp

and 0000001000000011 is the immediate field corresponding to a label you need to branch to if $s1 == $fp.
this binary number is an offset from the current position address.
meaning the label should be [0x00400000] + 0000 0010 0000 0011 ( sign extended offcource)
the branch address should be [0x00400000] + 0x203 = [0x00400203]

dont mind ... but i already know most of the stuff you told me

i am having a hard time printing values in hex .. or yeah maybe even obtaining value of a register in hex fomat!

i hope i made myself clear this time

sorry about the confusion

hbe02 Mar 26th, 2006 3:36 AM

sorry dude.. cant help you on this one. i havent really learnt how to use PCspim yet. but should be able to answer your question next week...
if you dont get your question answered by then ill post a new reply..

hbe02 Mar 26th, 2006 1:23 PM

was going through some mips code, just wanted to correct what i said earlier about branching. you take the immediate field and the new Program counter or address to branch to would be PC = (PC + 4) + (immediate* 4)
PC +4 because well this is how mips works....
immediate *4 because mips is byte adressable
this way in branching we can cover all 32-bits of the memory only by a 16 bit immediate field.. (PC+4) +/- 2^15


All times are GMT -5. The time now is 1:17 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC