Skip to content

Commit 91a8519

Browse files
committed
comment section fix
1 parent 5bf2fe7 commit 91a8519

1 file changed

Lines changed: 20 additions & 23 deletions

File tree

Experiment - 3/part3.asm

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,38 @@
1-
/*
2-
R10 is set to the address of arr, and R11 is set to the address of arr2.
1+
;----------------------------------------------
2+
; R10 is set to the address of arr, and R11 is set to the address of arr2.
33

4-
R12 is used as the index for the last element of arr (assuming that arr has 50 elements, 0-based index).
4+
; R12 is used as the index for the last element of arr (assuming that arr has 50 elements, 0-based index).
55

6-
The loop (reverseLoop) copies elements from the end of arr to the beginning of arr2,
7-
effectively reversing the order of the elements.
6+
; The loop (reverseLoop) copies elements from the end of arr to the beginning of arr2,
7+
; effectively reversing the order of the elements.
88

9-
After running this code, arr2 will contain the reverse order of the elements that were originally in arr.
9+
; After running this code, arr2 will contain the reverse order of the elements that were originally in arr.
1010

11-
You can adjust the size and starting addresses of arr and arr2 based on your specific requirements.
12-
*/
13-
14-
15-
; Allocate space in memory for arr and arr2
16-
a r r . s p a c e 100
17-
a r r 2 . s p a c e 100
11+
; You can adjust the size and starting addresses of arr and arr2 based on your specific requirements.
12+
;----------------------------------------------
1813

1914
; Initialize registers
2015
mov.w #arr, R10 ; Set R10 to the address of arr
2116
mov.w #arr2, R11 ; Set R11 to the address of arr2
2217
mov.w #49d, R12 ; Set R12 as the index for the last element of arr (0-based index)
2318

2419
; Start the loop to reverse arr and store it in arr2
25-
reverseLoop:
26-
; Copy the element from arr to arr2
27-
mov.w 0(R10), R13 ; Load the element from arr
28-
mov.w R13, 0(R11) ; Store it in arr2
20+
reverseLoop ; Copy the element from arr to arr2
21+
mov.w 0(R10), R13 ; Load the element from arr
22+
mov.w R13, 0(R11) ; Store it in arr2
2923

30-
; Move the pointers
31-
add #2d, R10 ; Move R10 to the next element in arr
32-
sub #2d, R11 ; Move R11 to the previous position in arr2
24+
; Move the pointers
25+
add #2d, R10 ; Move R10 to the next element in arr
26+
sub #2d, R11 ; Move R11 to the previous position in arr2
3327

34-
; Check if we have copied all elements
35-
cmp.w R10, R11 ; Compare R10 with R11
36-
jl reverseLoop ; If R10 is less than R11, continue the loop
28+
; Check if we have copied all elements
29+
cmp.w R10, R11 ; Compare R10 with R11
30+
jl reverseLoop ; If R10 is less than R11, continue the loop
3731

3832
; End of the program
3933

4034

35+
; Allocate space in memory for arr and arr2
36+
arr .space 100
37+
arr2 .space 100
4138

0 commit comments

Comments
 (0)