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, 9:59 PM   #41
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 8,368
Rep Power: 19 DaWei will become famous soon enoughDaWei will become famous soon enough
If this MIPS thangy is worth a poot in a windstorm, then you can almost certainly AND an immediate value like 1. Please understand that any number can be expressed in any base. 1 (decimal), 0x01 (hex), 0001b, all those things contain the same value in your machine. The representation is for your brain. Those all look alike, but many don't. 10 (decimal), 0x0A (hex), and 00001010 (binary) ALL REPRESENT THE SAME EXACT PATTERN INSIDE YOUR MACHINE. This is something you must realize and come to terms with.
__________________
Contributor's Corner:
Politically Incorrect
DaWei on Pointers
DaWei is offline   Reply With Quote
Old Dec 4th, 2006, 10:00 PM   #42
cwl157
Professional Programmer
 
Join Date: Feb 2005
Posts: 391
Rep Power: 10 cwl157 is on a distinguished road
.text

main:
	la $a0,prompt_in      #print prompt on terminal
	li $v0,4              #prints a string on the terminal
	syscall

	li $v0,5	      #reads in an integer
	syscall
	sw $v0,num1

	la $a0,prompt_ina      #print prompt on terminal
	li $v0,4               #prints a string on the terminal
	syscall

        li $v0,5	       #reads in an integer
	syscall
	sw $v0,num2

	lw $v0,num1		#set a
	lw $t0,num2		#set b

	xor $v1,$v0,$t0		# $v1 is c.  compare $v0 and $t0 and store in $v1

	move $s1, $zero		#s1 is the counter set to 0
	move $s2, $zero		#set hamming to 0
	li $s6,1		#set $s6 to 1
loop:
	and $s4,$v1,$s6		#s4 is d and c with d store in $s4	
	beq $s4, 0,nohamming	#jump to nohamming if $s4 is equal to 0
	addi $s2, $s2, 1	#increment hamming
	
nohamming:
	srl $v1, $v1, $s6	#shift c right by 1
	addi $s1, $s1, 1	#i = i + 1 increment loop counter
	ble $s1,32,loop		#if loop counter <=32 go to loop

print:
	la $a0,prompt_out      #print prompt on terminal
	li $v0,4              #prints a string on the terminal
	syscall

	move $a0, $s2		# syscall 1 prints an integer
	li $v0, 1
	syscall

	li $v0,10              #exit program
	syscall



.data
prompt_in:    .asciiz "Enter first integer: "            # first integer
prompt_ina:    .asciiz "Enter second integer: "          #second integer
prompt_out:   .asciiz "The hamming distance is "
num1: .word 0
num2: .word 0
again thank you so much for the help.
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 7:21 AM.

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