It's a MIPS question. Can anyone explain what's happened in the loop? Thank you. I need a deep explanation.
In loop, line 24,
$t0 is initially zero (0).
lb $t1, string($t0) --> this line takes the 1st element of string. (Index starts from 0).
Therefore t1 = 'A' , in other words it is equal to ascii decimal 65. The hexa value is 41.
For the table below, first column is decimal, next is hexa, then octa, then character and finally its name.
The next line 25,
beq $t1, $zero, exit
If $t1 is equal to zero it means there length of the string is exceeded. In other words, for ex, string is 'ABCDEFG' totally 7 letters. So if $t0 is 8, then string($t0) value is 0 (zero).
The next line 26,
blt $t1 , 'A' , continue
blt means branch if less than.
So if the letter is less than 'A', or less than 65, then goto continue. The continue increments the value of $t0 by 1. This is done because only alphabets can be converted to small case and not symbols as seen in the table above.
The 27th line also is used for the same purpose, ie., If $t1 greater than 'Z', then it is a symbol so goto continue so than $t0 can be incremented.
The next table helps in in understanding the 28th line.
As you see the small letter 'a' has the ASCII decimal 97.
So the difference between small letter and capital letter is 97 - 65 = 32 in decimal. Converting decimal 32 to hexadecimal is 20, hence addi (addition) of 0x20.
The 29th line stores the converted letter to string($t0) in its respective positition.
This loop keeps running until no character is read, in other words, until 0 is read.
Comment for doubts.
It's a MIPS question. Can anyone explain what's happened in the loop? Thank you. I need...