|
Professional Programmer
Join Date: Feb 2005
Posts: 344
Rep Power: 4 
|
alright now its saying that all the stuff in the .data section is undefined.
.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 #compare $v0 and $t0 and store in $v1
lw $v2, num3[i] #load the contents of num3[i] into $v2
move $v2,$v1 #move the conntents of $v1 into $v2
sw $v2, num3[i] #save the contents $v2 into num3[i]
#bit shift one bit
#repeat loop
loop:
#load array
#increment counter for each i
#return counter as hamming distance
la $a0,prompt_out #print prompt on terminal
li $v0,4 #prints a string on the terminal
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
#num3: .word 0,0,0 #array to hold 1's
Also any idea of what to initialize that array to. It's gonna have to be big enough to hold the largest of the numbers entered because it has to have enough spaces to hold one bit for each bit that the numbers are.
|