Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lab-1/fib.s
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@ fibonacci:

@ R4 = R0 - 0 (update flags)
@ if(R0 <= 0) goto .L3 (which returns 0)

subs r4, r0, #0
ble .L3
@ Compare R4 wtih 1
@ If R4 == 1 goto .L4 (which returns 1)

subs r0, r4, #1
beq .L4
@ R0 = R4 - 1
@ Recursive call to fibonacci with R4 - 1 as parameter

bl fibonacci
@ R5 = R0
@ R0 = R4 - 2
@ Recursive call to fibonacci with R4 - 2 as parameter

mov r5, r0
sub r0, r4, #2
bl fibonacci
@ R0 = R5 + R0 (update flags)

adds r0, r0, r5
pop {r3, r4, r5, pc} @EPILOG

@ END CODE MODIFICATION
Expand Down
25 changes: 20 additions & 5 deletions lab-2/mutex.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,34 @@
.global lock_mutex
.type lock_mutex, function
lock_mutex:
@ INSERT CODE BELOW

@ END CODE INSERT
@ INSERT CODE BELOW
ldr r1, =locked
.L1:
ldrex r2, [r0]
cmp r2, #0
bne .L2
strex r2, r1, [r0]
cmp r2, #0
beq .L1
dmb
bx lr
.L2:
wfe
b .L1
@ END CODE INSERT

.size lock_mutex, .-lock_mutex

.global unlock_mutex
.type unlock_mutex, function
unlock_mutex:
@ INSERT CODE BELOW

@ END CODE INSERT
ldr r1, =unlocked
dmb
str r1, [r0]
dsb
sev
@ END CODE INSERT
bx lr
.size unlock_mutex, .-unlock_mutex

Expand Down