View Single Post
Old Dec 4th, 2006, 3:20 PM   #18
cwl157
Professional Programmer
 
Join Date: Feb 2005
Posts: 333
Rep Power: 4 cwl157 is on a distinguished road
ok so i think i got i incrementing for the loop. Now how do I know when all the bits have been shifted and i can exit the loop? Also, i don't know how to print things i wish i could so i could see whats actually happening.
.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
	#move $a0,$v0
	#li $v0,1	      #prints integer
	#syscall

	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
	lw $t0,num2
	move $s1, $zero		#s1 is the counter
loop:
	addi $s1, $s1, 1	#i = i + 1
	
	xor $v1,$v0,$t0
	#bit shift one bit
	#compare those
	#keep going till there are no more bits
	#do the same thing but have the comparison be an and
	#then increment a counter for each 1 returned.
	#return counter as the hamming distance
	


	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
cwl157 is offline   Reply With Quote