EECS 373 - Fall 2026 - Lecture 3: Toolchain & ABI
Overview
The lecture explains how the GNU ARM toolchain turns C, assembly, and object files into executable images, then uses assembly examples to show how directives, labels, and memory addresses are resolved. It presents the ARM Application Binary Interface as a contract for function calls, including register responsibilities, argument and return locations, stack behavior, and preserving the link register during nested calls.
Key takeaways
- The GNU ARM toolchain links source files, object files, libraries, and a memory layout into a binary image; its disassembly gives the debugger a readable interpretation of that binary.
- Assembler labels represent addresses, not the data stored at those addresses; lower-16 and upper-16 relocations can build a label's address in a register.
- ARM calling conventions use R0 through R3 for arguments and caller-save scratch values, while R4 through R11 must be preserved by a function that modifies them.
- ARM function returns use R0 for 32-bit results, R0 and R1 for 64-bit results, and can use R0 through R3 for a 128-bit result.
- BL stores the caller's return address in LR, so a function making a nested call must save its own LR before the nested BL overwrites it.
- Protected, connector-equipped battery packs are appropriate for lab use; soldering cells or dismantling packs risks overheating, fire, or injury.
Chapters
- Homework 1 could be submitted late with a 10% penalty, and Homework 2 was due the following week.
- Embedded battery selection requires checking voltage, capacity in mAh, discharge rate, chemistry, cell count, and device current draw.
- A lithium-polymer cell labeled 3.7 V may charge to 4.2 V and should not be discharged below its safe range; voltage regulators provide a stable supply.
- Do not solder batteries or dismantle packs in the lab; use protected packs with connectors and ask lab staff for help.
- The course connects the stages from C to assembly to machine code so students can understand what higher-level IDE tools conceal.
- The GNU ARM toolchain combines compilers, binary utilities, debuggers, and standard libraries, with GCC as a core compiler tool.
- Compilation and linking combine C files, assembly, object files, libraries, and a memory layout to produce a binary image and disassembly.
- The binary contains instructions for memory, while the disassembly helps a debugger interpret and step through those instructions.
- Directives such as .global, .space, and .byte instruct the assembler rather than the processor; .space reserves zero-filled bytes and .byte places data in memory.
- Labels such as start and data name locations that the assembler or linker resolves to addresses.
- MOVW and MOVT can construct a 32-bit value in two steps, while a .W suffix requests a 32-bit instruction encoding.
- The example uses lower-16 and upper-16 relocations to form the address associated with the data label.
- The worksheet example places eight zero bytes in memory, then stores data bytes at successive locations.
- R1 receives the address resolved for the data label; LDRB then reads a byte from that address into R2.
- The loop increments its pointer and counter, adds values, compares the counter with four, and branches until the condition is met.
- A dead loop prevents the processor from continuing into unintended memory and interpreting arbitrary contents as instructions.
- The Application Binary Interface defines conventions for separately compiled code to share registers, memory, object formats, and stack behavior.
- Under the ARM procedure-call convention described in class, arguments use R0 through R3, starting with R0; additional data can be passed through memory or the stack.
- A 32-bit return value uses R0, a 64-bit value uses R0 and R1, and a 128-bit value can use R0 through R3.
- R0 through R3 are caller-save scratch registers, so a caller must preserve any values it needs across a function call.
- R4 through R11 are callee-save registers, so a function that modifies them must restore their original values before returning.
- The class treats R9 as a callee-save register, while noting that its platform-specific role can vary.
- R12 is caller-save scratch space; R13 is the stack pointer, R14 is the link register, and R15 is the program counter.
- BL branches to a function and records the return address in LR; BX LR returns by branching to the address held in the link register.
- The example passes 3 in R0 and 4 in R1 before calling the square function.
- BL square updates LR with the address of the instruction after the call, allowing the function to return to its caller.
- The function squares its inputs, adds the results, and places the returned value in R0.
- The example distinguishes ABI requirements from implementation choices: temporary calculations can use other registers as long as the required return value is in R0.
- A function that changes a callee-save register such as R4 must push its original value and pop it back before returning.
- The stack grows toward lower memory addresses, and push or pop adjusts the stack pointer while transferring register values.
- Register-list push and pop encodings use a bit mask, so register ordering is not an instruction-level guarantee; programmers must keep save and restore sequences consistent.
- Pushing and popping the same register set avoids errors caused by mixing individual restores with multi-register saves.
- In the nested-call example, quad calls square, so quad must save its own LR before BL square overwrites it.
- After square returns, quad restores LR from the stack and uses BX LR to return to its original caller.
- A function that does not make another call can often return directly without saving LR, while nested calls require preserving the return chain.
- The closing review emphasizes that raw GNU toolchain components offer control when an IDE fails and that ABI rules make functions interoperable.
Transcript excerpt
0:00 We're going to be talking about tool chain and the application binary interface. So, homework one was due yesterday. Uh today you can do uh submit it late for five or 10 point penalty or 10% penalty. Homework two has been posted and is due next week. Um and then we finally got um room assignments for our midterms and our team formation event. And you won't remember and I I'll remind you later, but uh we'll have a list that defines which people go to which room when it's exam day. I think it's already on the the website. But those are the logistics. Any logistics questions before we begin? Nope. All right. So, talk about uh component of the day I like this be just because it gives
0:47 people a breath of a lot of the knowledge that we just kind of assume students know. And then maybe some of the students know it and some of the students don't. So, um a lot of times we think about batteries from the consumer side where it's just these like predefined nickel metal hydrides, they're super safe. They have the same everything is about the same voltage based on 1.5 volts. And they're just kind of like plug and play. When you get to the embedded systems world, you have a lot more choices and usually it's in these uh packs and pouches where you're trying to optimize uh your battery performance for your particular device. And so now you got to think about things like runtime and current draw and rechargeability. And of course, one of the key metrics is voltage, but now you stop to start thinking about capacity. And they don't you would think that they would talk about capacity in terms of like energy
1:33 or maybe runtime, but instead they they
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Interactive Sensing and Computing Lab.