Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 24th, 2006, 9:32 AM   #1
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
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!
programmingnoob is offline   Reply With Quote
Old Mar 24th, 2006, 10:11 AM   #2
MBirchmeier
Hobbyist Programmer
 
Join Date: Oct 2005
Posts: 211
Rep Power: 3 MBirchmeier is on a distinguished road
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
MBirchmeier is offline   Reply With Quote
Old Mar 24th, 2006, 11:37 AM   #3
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
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 is offline   Reply With Quote
Old Mar 24th, 2006, 12:10 PM   #4
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
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 is offline   Reply With Quote
Old Mar 26th, 2006, 12:45 AM   #5
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
help?? please!!!!!
programmingnoob is offline   Reply With Quote
Old Mar 26th, 2006, 2:03 AM   #6
hbe02
Hobbyist Programmer
 
hbe02's Avatar
 
Join Date: Mar 2006
Location: Lebanon
Posts: 148
Rep Power: 3 hbe02 is on a distinguished road
[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]
hbe02 is offline   Reply With Quote
Old Mar 26th, 2006, 2:37 AM   #7
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
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
programmingnoob is offline   Reply With Quote
Old Mar 26th, 2006, 3:36 AM   #8
hbe02
Hobbyist Programmer
 
hbe02's Avatar
 
Join Date: Mar 2006
Location: Lebanon
Posts: 148
Rep Power: 3 hbe02 is on a distinguished road
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 is offline   Reply With Quote
Old Mar 26th, 2006, 1:23 PM   #9
hbe02
Hobbyist Programmer
 
hbe02's Avatar
 
Join Date: Mar 2006
Location: Lebanon
Posts: 148
Rep Power: 3 hbe02 is on a distinguished road
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
hbe02 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:58 AM.

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