Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Aaron Erhardt
Cheatsheets
Commits
d2524393
Commit
d2524393
authored
May 11, 2021
by
Aaron Erhardt
Browse files
Improve code formatting
Signed-off-by:
Aaron Erhardt
<
aaron.erhardt@t-online.de
>
parent
f3ee3cbe
Pipeline
#545
passed with stage
in 1 minute and 54 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Mikrocomputertechnik/asm.md
View file @
d2524393
...
...
@@ -190,7 +190,7 @@ label
```
asm
main
ldr r0, =1 ; initialize parameters
ldr r0, =1
; initialize parameters
ldr r1, =2
bl add_nums ; run subroutine
; r2 can now be used as returned value
...
...
@@ -210,24 +210,25 @@ main
ldr r8, =2
; prepare parameters and return values
push {r7} ; parameter 1
push {r8} ; parameter 2
push {r9} ; return value 1
push {r7}
; parameter 1
push {r8}
; parameter 2
push {r9}
; return value 1
bl add_nums ; run subroutine
pop {r9} ; get return value from the stack
pop {r8} ; free stack space again
pop {r7} ; free stack space again
pop {r9}
; get return value from the stack
pop {r8}
; free stack space again
pop {r7}
; free stack space again
add_nums
push {lr, r0-r2} ; increments stack pointer by 4 * (amount of registers)!
; increments stack pointer by 4 * (amount of registers)!
push {lr, r0-r2}
; load parameters into registers
ldr r0, [sp, #4*6] ; 4*4 + 4*2 -> r7 (
was
pushed first
,
highest address)
; load parameters into registers
ldr r0, [sp, #4*6] ; 4*4 + 4*2 -> r7 (pushed first
->
highest address)
ldr r1, [sp, #4*5] ; 4*4 + 4*1 -> r8
add r2, r0, r1 ; perform actual calculation
add r2, r0, r1
; perform actual calculation
; store return values on reserved the stack space
str r2, [sp, #4*4] ; 4*4 + 4*0 -> r9
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment