Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Dec 4th, 2006, 7:23 PM   #21
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 810
Rep Power: 4 The Dark is on a distinguished road
well you have two "loop:" lines, so that might be causing a problem.
I don't think you need to put anything in an array. Try some code like this:
[code]
get a
get b

xor a and b into c

set loopCounter to 0
set hamming = 0
loop:
and c with 0x01 into d
if d == 1
increment hamming
shift c right by 1
increment loopCounter
if loopCount <= 32*
goto loop

print hamming

* replace 32 by whatever number of bits you have in your integer

Note: you already have some of this code
The Dark is offline   Reply With Quote
Old Dec 4th, 2006, 7:56 PM   #22
cwl157
Professional Programmer
 
Join Date: Feb 2005
Posts: 323
Rep Power: 4 cwl157 is on a distinguished road
Thanks for the code. A couple questions though: i thought loop was a reserved word that you put everytime you want to loop but i guess not? Also what do you mean by
and c with 0x01 into d.
What does the 0x01 mean?
cwl157 is offline   Reply With Quote
Old Dec 4th, 2006, 7:58 PM   #23
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 810
Rep Power: 4 The Dark is on a distinguished road
No I'm pretty sure loop is just a label that you want to jump to.

0x01 is hexadecimal notation for 1. I should have just written 1 there instead. ANDing with 1 gives you the value of the least significant bit.
The Dark is offline   Reply With Quote
Old Dec 4th, 2006, 8:06 PM   #24
cwl157
Professional Programmer
 
Join Date: Feb 2005
Posts: 323
Rep Power: 4 cwl157 is on a distinguished road
so you think i have to write it like 0x01 or do i have to load one into another register and then use that register in the and condition because the one reference i have said and has 3 registers associated with it one for the result and then 2 that are being compared but if i know the number im always comparing it to you think i could just write that?
cwl157 is offline   Reply With Quote
Old Dec 4th, 2006, 8:11 PM   #25
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 810
Rep Power: 4 The Dark is on a distinguished road
No I don't think you should write it like 0x01 that is why i said:
Quote:
I should have just written 1 there instead.
I don't know whether you can just put a value in instead of a register, I don't know any MIPS assembler. I would guess that you could, but if you can't then just load the 1 into another register and use that register.
The Dark is offline   Reply With Quote
Old Dec 4th, 2006, 8:24 PM   #26
cwl157
Professional Programmer
 
Join Date: Feb 2005
Posts: 323
Rep Power: 4 cwl157 is on a distinguished road
yea i loaded one into another register and used that and i got no errors when i loaded it into the simulator im using so thats a good sign. Now i have one more question. When you said
Quote:
* replace 32 by whatever number of bits you have in your integer
. I have to make this to handle any 32 bit integer so could i keep it at 32 and would it work even if the integer is smaller than 32?
cwl157 is offline   Reply With Quote
Old Dec 4th, 2006, 8:27 PM   #27
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 810
Rep Power: 4 The Dark is on a distinguished road
If your integers are 32 bit, it doesn't matter what value they have in them, they are still 32 bit. I was only pointing out that if you are doing this for a 64 bit integer, you will need to change the loop count.
The Dark is offline   Reply With Quote
Old Dec 4th, 2006, 8:34 PM   #28
cwl157
Professional Programmer
 
Join Date: Feb 2005
Posts: 323
Rep Power: 4 cwl157 is on a distinguished road
o ok cool now i seem to not be able to find the less than or equal to command but it has to be here somewhere right because they have less than or equal to 0 but not less than or equal to any number you wan to put there.
cwl157 is offline   Reply With Quote
Old Dec 4th, 2006, 8:39 PM   #29
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 810
Rep Power: 4 The Dark is on a distinguished road
http://www.google.com.au/search?hl=e...G=Search&meta=
The Dark is offline   Reply With Quote
Old Dec 4th, 2006, 8:39 PM   #30
cwl157
Professional Programmer
 
Join Date: Feb 2005
Posts: 323
Rep Power: 4 cwl157 is on a distinguished road
im an idiot i could just use the branch if one is less than the other and then right after it i could put branch if one is equal to the other and then just make them both branch to the same place and its the same thing right?
cwl157 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Assembly Language for Intel-Based Computers melbolt Book Reviews 0 Aug 15th, 2006 12:04 AM
Language display in program Prm753 C++ 3 May 30th, 2006 5:45 PM
More languages? UnKnown X Coder's Corner Lounge 27 Dec 18th, 2005 3:06 PM
Does assembly language vary per machine? Xero Assembly 9 Jan 17th, 2005 11:34 AM




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

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