Assignment 4 210
Assignment 4 210
8:
Code Used:
Theory: Here the string used is “Open college please”, which is not a palindrome. If the
string is a palindrome ‘1’ is stored in register R4, if not ‘0’. The reversed string is stored in
the address 0x40000100.
Execution:
We can clearly observe that the value in register R4 is 0 since the given string is not a
palindrome
Execution For a Palindrome(Malayalam):
We can clearly observe that Malayalam is a palindrome so the value in register R4 is set to 1.
4.9
Code Used:
If the given substring is present in the string then the register R3 is set to ‘1’ if not ‘0’ in
this example our main string is ‘Many Submissions in weekend’, the sub string needed to
search is ‘in’. Since in is present in the main string the register R3 should be ‘1’ after
execution. We need to specify the length of the substring to the constant Len. The value
of Len and the length of the substring needs to be equal.
Execution:
Since in is present in the main string the value in the register R3 is set to 1, this can be
seen in the below executed figure, we also executed to find “in n”, which is 4bytes long
and not present in the main string. So we need to get ‘0’ in the register R3.
Both pictures of execution is attached below.
Since ‘in’ is present in the main string the value of R3 is One.
Here we tried to search ‘in n’ in the main string which is not present so the value in the
register R3 is Zero.
4.10
Code Used:
The main string present here is “Hell of a job” we are going to insert “Not” at starting
of the string the combined string is saved in 0x40000000 address location. We need
to specify the position where the string needs to be inserted. Here we are inserting
string at the start so the POS is 0.
Execution:
We can clearly observe that the string not got embedded into the main string and
stored near the memory location 0x40000000.
The location to be inserted can be changed by changing the value of POS.
4.11
Code Used:
The ascii value of the Gap is 0x20, we read the character in the string one by one and
compare it with the Gap(0x20), if the character doesn’t match with gap we store it again
in the position, if it matches with gap we read the next character without storing it in its
position. By doing this we will be able to squeeze the string. This can be observed when
the code is executed.
Execution:
We can see the number 20 i.e the gap in the main string before execution.
We can observe that there are no 20’s in the squeezed string. 00 indicated end of the
string.
**************************Thank You*****************************