Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Lab 3:

String manipulation and memory addressing


Abstract:
The motivation behind this lab was to pick up string control and memory
addressing. We needed to compose a program that would duplicate a string starting
with one area then onto the next. Be that as it may, the program was likewise to kill
spaces between the characters while replicating the string. To do this we needed to
make space for the first message, objective message, and duplicate each person in
turn as lengthy as that space was not a space character. Then, utilizing similar
technique we had to the string and duplicate it in reverse in the event that it began
with a lower-case letter, wavy section or tilde. In any case, the string must be
duplicated forward like in the past part.
Challenge:
In this lab, we were able to implement the knowledge learned in class about
subroutines and comparison functions to copy a string over without the spaces. If
the character that was being checked was a space, it would start the loop over
without copying the character over, so that the final product had no spaces in it.
For the last part, the string would be copied forward, or backward based on if the
first letter was lower-case, a curly bracket or a tilde. This worked because if the
character being compared was greater than the ascii value of a lower-case ‘z’, then
it would start the forward copying subroutine and the backward copying subroutine
otherwise.
Approach:
The main thing was to proclaim "I'm a Cane" as .asciz. A while later, I made a
subroutine that contrasted each person with check whether it was a space or not.
On the off chance that it was, I would call the subroutine again prior to replicating
the person, so just letters would be duplicated. For the last part notwithstanding, I
really look at the main person of the string and in the event that it was lower-case a
wavy section or a tilde I called the retrogressive subroutine rather than the forward
subroutine. This would do exactly the same thing but begin at the last person and
move in reverse.
Experiment setup:
I created a subroutine for the forward copying, and one for the backward copying.
Depending on the first character, I would call one of these two subroutines.
Results/Answers:
The program was successfully working. The code was the following
.data

source: .asciz "I am a Cane"

dest: .space 100,0

.text .global _start

_start:

ldr r3, =dest

ldr r1,=source

ldrb r5, [r1]

subs r5,r5,#61

blt loopf

loopb:

gb: ldr r7, =source

ldrb r6,[r7],#1

cmp r6,#0

bne gb

loop:

subs r8,r7,r1

blt loope

ldrb r6,[r7],#-1

cmp r6,#' '

beq loop

strb r6,[r3],#1

b loop
loopf:

ldrb r2, [r1],#1

cmp r2,#0

beq loope

cmp r2,#' '

beq loopf

strb r2,[r3],#1

b loopf

loope:

.end

With constant revisions and compilings, I have slowly come to understand string
manipulation and memory addressing. During review at the lab I was able to fully
comprehend and elaborate on my findings as expressed throughout this report.
With each explanation the TA would support my claims and help me dive further
into why and how the computer follows each instruction and manipulates the
string. In the end, my code has been able to function for all the parts that I have
completed.
Figures and Tables:
Figure 1:

Figure 2:

Figure 3:

Figure 4:
Conclusion:
In the end, this lab was successful because I was able to copy a string from one
memory location, both backwards and forward, while removing all of the spaces
that were originally in the string.

You might also like