diff --git a/semester3/spca/code-examples/01_asm/01_sum.s b/semester3/spca/code-examples/01_asm/01_sum.s new file mode 100644 index 0000000..559552b --- /dev/null +++ b/semester3/spca/code-examples/01_asm/01_sum.s @@ -0,0 +1,13 @@ +sum: // Label + endbr64 // Indirect Branch target (No effect on code's logic) + pushq %rbp // Preserve caller stack frame + movq %rsp, %rbp // Set up new stack frame + movl %edi, -20(%rbp) // Arg1 register -> stack + movl %esi, -24(%rbp) // Arg2 register -> stack + movl -20(%rbp), %edx // stack[Arg1] -> gp register + movl -24(%rbp), %eax // stack[Arg2] -> gp register + addl %edx, %eax // Add Arg1 + Arg2 -> gp register + movl %eax, -4(%rbp) // result -> stack + movl -4(%rbp), %eax // stack[result] -> return register + popq %rbp // Restore caller stack frame + ret // jump back to caller \ No newline at end of file diff --git a/semester3/spca/parts/00_asm/00_intro.tex b/semester3/spca/parts/00_asm/00_intro.tex index a2c96ba..7ee04ca 100644 --- a/semester3/spca/parts/00_asm/00_intro.tex +++ b/semester3/spca/parts/00_asm/00_intro.tex @@ -35,3 +35,9 @@ Today, the choices are made based on outside constraints usually. For desktops a For embedded systems though, the reduced complexity of RISC makes more sense, but for how long still? What matters most today are non-technical factors such as existance of code for one ISA or licensing costs (and of course, Geopolitics) + +\shade{purple}{Example} A \verb|C| function that simply adds $2$ arguments might be compiled (unoptimized) to this: + +\inputcodewithfilename{gas}{code-examples/01_asm/}{01_sum.s} + + diff --git a/semester3/spca/spca-summary.pdf b/semester3/spca/spca-summary.pdf deleted file mode 100644 index 45a146f..0000000 Binary files a/semester3/spca/spca-summary.pdf and /dev/null differ