Islamic University-Gaza Faculty of Engineering Computer Department Project For Computer Architecture Names:Suhair Dawoud ID :22008 1464 Nedaa Jaber ID:2008 0716 To:Eng.Doaa Abu Jabal Objectives: The basic objective of this Project is to calculate the difference between two strings and comparing each character in the first string with the character at the same index in the second string then display the result. Brief Details: This code contains one loops and jumps as described below: Loop in the procedure “comp” to take the elements from the specific index that we are interested in from the first array to compare it with element from the second array at the same index, if its not equal the ith will be increment each time also the count will increments with one . Then, the count is now having the number of different chars by move it to $v0 and then use the integer print instruction to print the difference . procedure to compare and count the different between the two arrays then return the result in $v0 . Java code : The output: The Code: .data Array1: .word 's',u','h','a','i','r' Array2: .word 's','a','h','a','r' msg0: .asciiz "The difference between two strings =" # asciiz is terminated string msg1: .asciiz "The difference between the two strings in length "= msg2: .asciiz "The number of different characters in the two strings "= msg3: .asciiz "The First name:suhair\n " msg4: .asciiz "The second name:sahar\n" newline: .asciiz "\n" .text main: ## print the first name la $a0,msg3 li $v0,4 # syscall # syscall prints whatever found in $a0 is code for print string # execute system call ## print the second name la $a0,msg4 li $v0,4 4# syscall # syscall prints whatever found in $a0 is code for print string # execute system call $ # s1 -lenght of array1 $ # s2 -lenght of array2 addi $s1,$zero,6 addi $s2,$zero,5 la $s6,Array1 la $s7,Array2 # load adress of the array into s6 #load adress of the array into s7 # comparing the length of two array bne $s1,$s2,l1 add $a0,$zero,$s2 jal comp move $t5,$v0 # s1!=s2 go to L1,else go to next step # s2 :lenght of array # v0:the no.of diffrenent chars from the proc ## print msg2 and the answer la $a0,msg2 # syscall prints whatever found in $a0 li $v0,4 4 # is code for print string syscall move $a0,$t5 li $v0,1 syscall la $a0,newline li $v0,4 syscall # a0= v0 bcz syscall prints whatever found in $a0 # 1 is code for print int # print new line # print the msg1 and the answer la $a0,msg1 li $v0,4 syscall addi $t7,$zero,0 # a0=0 bcz there are no different between lenght we print 0 move $a0,$t7 li $v0,1 syscall la $a0,newline li $v0,4 syscall # print new line # print msg0 and the answer la $a0,msg0 li $v0,4 syscall move $a0,$t5 li $v0,1 syscall la $a0,newline li $v0,4 syscall j exit # exit the programe l1: bgt $s1,$s2,big blt $s1,$s2,small # if s1> s2 go to big # if s2<s1 go to small big : add $a0,$zero,$s2 jal comp # s2 "the lenght of small array" move $t0,$v0 sub $t3,$s1,$s2 add $t4,$t3,$t0 # v0 "The number of different characters" # sub the small lenght from big lenght "t3=s1-s2" # add the diff lenght and diff characher # print msg2 and the answer la $a0,msg2 li $v0,4 syscall move $a0,$t0 li $v0,1 syscall la $a0,newline li $v0,4 syscall #print msg1 and the answer la $a0,msg1 li $v0,4 syscall move $a0,$t3 li $v0,1 syscall la $a0,newline li $v0,4 syscall # print msg0 and the answer la $a0,msg0 li $v0,4 syscall move $a0,$t4 li $v0,1 syscall la $a0,newline li $v0,4 syscall j exit small : add $a0,$zero,$s1 jal comp move $t0,$v0 # t0= v0 "The number of different characters " sub $t3,$s2,$s1 # code to sub the small lenght from big lenght "t3=s2-s1" add $t4,$t3,$t0 # code to add the diff lenght and diff characher "t4=t3+t0" ## print msg2 and the answer la $a0,msg2 li $v0,4 syscall move $a0,$t0 li $v0,1 syscall la $a0,newline li $v0,4 syscall # print msg1 and the answer la $a0,msg1 li $v0,4 syscall move $a0,$t3 li $v0,1 syscall la $a0,newline li $v0,4 syscall # print msg0 and the answer la $a0,msg0 li $v0,4 syscall move $a0,$t4 li $v0,1 syscall la $a0,newline li $v0,4 syscall j exit comp: #s5 for i #s0 for counter add $s0,$zero,$zero add $s5,$zero,$zero loop: # slt $t2,$s5,$a0 beq $t2,$zero,final # counter=0 # i=0 a0= lenght of small array , s5=i sll $t4,$s5,2 add $s3,$t4,$s6 lw $t2,0($s3 ) add $s4,$t4,$s7 lw $t3,0($s4) addi $s5,$s5,1 beq $t2,$t3,returncount addi $s0,$s0,1 #counter++ j loop returncount j loop : final: move $v0,$s0 jr $ra exit: li $v0,10 syscall Screen shot of the output: Conclusion: I found some problem but I can overcome it by hard work and have some experience .
© Copyright 2026 Paperzz