ARM Assembly: Lesson 11 (Stack Operations)

  Рет қаралды 6,090

LaurieWired

LaurieWired

Күн бұрын

Welcome to Lesson 11 of the ARM Assembly Series from LaurieWired!
In this video, we learn how to allocate space on the stack by directly modifying the stack pointer. We use the stack to pass additional arguments to a function.
---
Timestamps:
00:00 Intro
00:40 Adding Six Numbers
02:39 Allocating Space on the Stack
04:39 Substracting the stack pointer
06:11 Adding Numbers (Loading Registers)
07:52 Running Program
10:10 Stepping into Function Call
11:37 Examining Memory
12:07 Recap
---
Links Mentioned in Video:
CPULator:
cpulator.01xz.net/?sys=arm
---
laurieWIRED Twitter:
/ lauriewired
laurieWIRED Website:
lauriewired.com
laurieWIRED Github:
github.com/LaurieWired
laurieWIRED HN:
news.ycombinator.com/user?id=...
laurieWIRED Reddit:
/ lauriewired

Пікірлер: 29
@JohnJolly
@JohnJolly 7 ай бұрын
I'm an old grizzled assembly language programmer. You presentation of stack operations is blissfully pleasant. I will be watching your other videos and very likely recommending your videos to my students. Thank you for being awesome.
@ChineseRatfaceCHANG
@ChineseRatfaceCHANG 3 ай бұрын
We all know assembler it isn't difficult
@bensergentanis496
@bensergentanis496 2 ай бұрын
These are awesome! I've gone through the series and learned enough to write a little function that computes factorials for positive and negative numbers! Please make more of these if you can!
@alexweymans
@alexweymans Ай бұрын
Thank you for this series! I learned a lot.
@fabiano9277
@fabiano9277 7 ай бұрын
Thank you for all your videos Laurie. There is so much to learn for me. 🙏 You are awesome. 🎉
@martinkinyanjui7237
@martinkinyanjui7237 7 ай бұрын
Probably the best channel to learn asm. Thanks!!
@maxcnunes
@maxcnunes 2 ай бұрын
Great content! Thanks so much for this series on ARM. I have learned so much, I can finally understand a bit of assembly.
@ScythianSerb
@ScythianSerb 7 ай бұрын
you definitely deserve more subscribers, trying to get into Reverse Engineering and this really helps
@ArjanvanVught
@ArjanvanVught 2 ай бұрын
Thanks for all your effort! Great content!
@HyperDefective
@HyperDefective 7 ай бұрын
I just found your channel by accident. One of your videos popped up and while it wasn't really relevant to what I needed (trying to figure out why a particular app won't work on any Android emulator I try), I felt the need to stop by and say that the editing and style on your videos is amazing. Your thumbnails, too. As a fellow aspiring KZbinr (with totally different subject matter), I can only hope to be as dedicated. I was legitimately shocked to see that you didn't have a crazy amount of subscribers. Keep up the good work!
@SaintMorning
@SaintMorning 7 ай бұрын
awesome series. love the style and editing!
@JPEaglesandKatz
@JPEaglesandKatz 4 ай бұрын
I've been a hobby amateur coder (from atari basic in 1980 to 6502 assembly on that same system, pascal, turbo pascal, vb, vb .net, some C#) but all in mostly hobby scene.. and I am not very good at it at all lol.. Your way of explaining modern assembly might actually make me delve into some ASM again!!! Your videos are awesome!!!! you are awesome!! You bring everything with such enthusiasm!
@pf4877
@pf4877 4 ай бұрын
Thanks for getting me started on assembly!
@tringuyenminh7568
@tringuyenminh7568 Ай бұрын
tks for all ^^
@telmani2624
@telmani2624 3 ай бұрын
Pretty lady explains pretty good :) thank you so much for your lessons!
@man832
@man832 7 ай бұрын
thank you
@chudchadanstud
@chudchadanstud 7 ай бұрын
Thanks for the vid, the content is good, the pacing is appreciated and styling is cool. However the styling can be a bit distracting at times especially when it zooms in and out or when text pops in while hiding the code. I say reduce the noise and focus more on the content. Make the text size bigger too. Anyways great vid 👍
@joebrewer1892
@joebrewer1892 2 ай бұрын
Loving this content. What is the benefit of modifying the stack pointer and using str as opposed to using push and pop?
@oliverdowning1543
@oliverdowning1543 5 күн бұрын
From what I can tell, after asking copilot. the main concern here might be how it performs at scale. Since 1 register: r4, is being used for each value being passed to the stack, you would need a separate push operator for every value. Since we know how far the stack pointer will have gone, we can just move the stack pointer once at the start then only call a store operator for each value which uses fewer CPU cycles than the push operator since it doesn’t need to change the stack pointer itself. You can imagine that if you’re calling many functions with large numbers of arguments then saving a handful of CPU cycles for every function call might be helpful. Maybe there’s some other, more technical, reason as well, but hopefully that provides a fairly satisfying answer (even if I’m nowhere near qualified to actually answer the question and I just asked CoPilot and I’m secretly hoping that if I’m wrong then someone more experienced will now swoop in to correct me).
@giamagg4602
@giamagg4602 7 ай бұрын
🙌
@ctbram0627
@ctbram0627 7 ай бұрын
What if I want a function that returns more the just one value in r0? I cpulater does not like if I try to push return values on the stack. Upon returning to the calling routine and trying to pop the values pushed to the stack from the function it crashes complaining I have "clobbered" the sp??? Help please
@dr3dr356
@dr3dr356 11 күн бұрын
You need a pointer to return multiple values, just like in C. Higher language just abstract it for u by unpacking the return through pointer arithmetic's. You should not manipulate the SP during function execution, think about it like a link-list if you cut off the head of the list you lost the whole list and also if you cut of the tails you lose the whole list in a double link list and just that data in a single link list
@ctbram0627
@ctbram0627 7 ай бұрын
In the new program, it does not appear that you preserve the r0 register. upon return, you move the result to r2, de-allocate the stack space, and then pop the lr. But r0 still holds the accumulated sum of 21 correct? Not sure I understand pushing then popping the LR? At the end of the program, you have just set the lr back to pointing the value it was at the start of the program. I am having trouble seeing the point of that? Why not just let it point the line after the last line of the program where you can branch to _end?
@nickiascerinschi206
@nickiascerinschi206 27 күн бұрын
I am having issues understand lr part too. I understood the intention at the beginning of the video of lr just preserving it so the whole program isn't confused and can carry on but isnt str r4, [sp] affecting the stack and when you do pop {lr} it will put #6 into lr so 0x0000(#6 in hex) as address which is wrong. As usually most of the tutorials contain mistakes, wrong examples and little explanation. But as usually just read docs and try to implement the stuff by yourself and we should be fine.
@nickiascerinschi206
@nickiascerinschi206 27 күн бұрын
and... here is the answer: Here's why saving and restoring LR might be necessary: Preservation of the Calling Function's State: When a function makes a call to another function (BL), it's essential to preserve the caller's return address. If you don't preserve LR before making a function call (BL), the callee function may overwrite it with its own return address. Saving LR before the call (PUSH {LR}) ensures that the return address of the calling function is preserved, and it can be restored later. Restoring the Return Address: After the callee function completes its execution, it needs to return control to the calling function. To do this correctly, the return address stored in LR before the function call (PUSH {LR}) needs to be restored. This is done by popping the return address off the stack and placing it back into LR before executing the POP {PC} instruction, which effectively returns control to the caller.
@nickiascerinschi206
@nickiascerinschi206 27 күн бұрын
And she explained at 2:27 that it is useless but in the future if you are inside the function you might do that because you wanna return to whatever next instruction needs to be executed and also she kept it here for the sake of showing you how "stack is growing downwards" in this case when u do push {lr} it did sub lr, lr, #4 then str lr, [sp] so basically doing: push {lr} is same as 1) sub lr, lr, #4 ; 2) str lr, [sp]. Also you can translate it to: stmdb sp! {lr}. Now that I did write this I understood the thing 100%.
@FarmerFletcher
@FarmerFletcher 7 ай бұрын
shoutout to /g/
@VIVIan-us9zk
@VIVIan-us9zk 7 ай бұрын
slay
Dynamically Analyzing Linux Black Basta Ransomware
24:33
LaurieWired
Рет қаралды 17 М.
RISC-V Assembly Hello World (Part 1)
11:43
LaurieWired
Рет қаралды 22 М.
狼来了的故事你们听过吗?#天使 #小丑 #超人不会飞
00:42
超人不会飞
Рет қаралды 65 МЛН
Make me the happiest man on earth... 🎁🥹
00:34
A4
Рет қаралды 8 МЛН
КАРМАНЧИК 2 СЕЗОН 6 СЕРИЯ
21:57
Inter Production
Рет қаралды 509 М.
Indian sharing by Secret Vlog #shorts
00:13
Secret Vlog
Рет қаралды 62 МЛН
Ep 081: Introduction to the Stack Pointer
16:09
Intermation
Рет қаралды 46 М.
Using Recursion in ARM Assembly to compute the Fibonacci Sequence
15:58
Ghidra Scripting to Speed Up Reverse Engineering
17:24
LaurieWired
Рет қаралды 14 М.
Pointers in RISC-V Assembly
19:42
LaurieWired
Рет қаралды 13 М.
everything is open source if you can reverse engineer (try it RIGHT NOW!)
13:56
Low Level Learning
Рет қаралды 1,2 МЛН
how hello world for arm64 assembly really works (apple silicon)
30:59
Cybersecurity "Experts" suck at coding.  It's a problem.
15:12
LaurieWired
Рет қаралды 96 М.
Comparing C to machine language
10:02
Ben Eater
Рет қаралды 5 МЛН
What model of phone do you have?
0:16
Hassyl Joon
Рет қаралды 78 М.