<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Assembly on Lloyd Rochester's Geek Blog</title><link>https://lloydroc.github.io/tags/assembly/</link><description>Recent content in Assembly on Lloyd Rochester's Geek Blog</description><generator>Hugo</generator><language>en</language><copyright>Copyright © 2025, Lloyd Rochester.</copyright><lastBuildDate>Fri, 11 Jun 2021 00:00:00 +0000</lastBuildDate><atom:link href="https://lloydroc.github.io/tags/assembly/index.xml" rel="self" type="application/rss+xml"/><item><title>Stack Protection with a Canary</title><link>https://lloydroc.github.io/post/c/stack-protection-canary/</link><pubDate>Fri, 11 Jun 2021 00:00:00 +0000</pubDate><guid>https://lloydroc.github.io/post/c/stack-protection-canary/</guid><description>&lt;h1 id="hahahugoshortcode41s0hbhb">Stack Protection with a Canary&lt;/h1>
&lt;p>Buffer overflows can be detected by inserting a &lt;em>canary&lt;/em> into a function. These canaries are inserted when a function&amp;rsquo;s stack frame is created. Before a function&amp;rsquo;s return we check for the canary on the stack frame. If the canary isn&amp;rsquo;t found then buffer overflow or &lt;em>stack smashing&lt;/em> is detected.&lt;/p>
&lt;h1 id="example">Example&lt;/h1>
&lt;p>Let&amp;rsquo;s first create a deliberate buffer overflow. Then we can see how it behaves with and without stack protection.&lt;/p></description></item><item><title>Disassembly of Recursion in C</title><link>https://lloydroc.github.io/post/c/arm-assembly-recursion/</link><pubDate>Fri, 25 Sep 2020 00:00:00 +0000</pubDate><guid>https://lloydroc.github.io/post/c/arm-assembly-recursion/</guid><description>&lt;h1 id="hahahugoshortcode19s0hbhb">Disassembly of Recursion in C&lt;/h1>
&lt;p>Let&amp;rsquo;s disassemble a recursive function in C to ARM assembly. We can use the textbook example of a recursive factorial function. We&amp;rsquo;ll play around with optimization levels and touch on Tail Recursion or Tail Calls at the end of the blog post.&lt;/p>
&lt;h2 id="c-code">C Code&lt;/h2>
&lt;p>Below is the C code we&amp;rsquo;ll use to disassemble. This code is a text book function that implements a factorial using recursion.&lt;/p></description></item><item><title>The Stack of Frames in C with ARM Assembly Example</title><link>https://lloydroc.github.io/post/c/stack-of-frames-arm/</link><pubDate>Fri, 03 Apr 2020 08:34:05 -0600</pubDate><guid>https://lloydroc.github.io/post/c/stack-of-frames-arm/</guid><description>&lt;p>Function calls in the C programming language make heavy use of the stack, also called the call stack. When functions are called they create the so-called stack of frames. Each function call creates a frame, and these frames are allocated on the stack. This stack frame is used to allocate memory for local variables and intermediate values. The stack frame also contains the previous frame pointer and program counter&amp;rsquo;s value to execute from once the frame is popped off the stack. We will disassemble C function calls to understand the stack of frames in ARM assembly.&lt;/p></description></item><item><title>Converting C Conditionals to ARM Assembly</title><link>https://lloydroc.github.io/post/c/arm-assembly-conditionals/</link><pubDate>Fri, 27 Mar 2020 00:00:00 +0000</pubDate><guid>https://lloydroc.github.io/post/c/arm-assembly-conditionals/</guid><description>&lt;h1 id="hahahugoshortcode12s0hbhb">Converting C Conditionals to ARM Assembly&lt;/h1>
&lt;p>In this post we can explore how to the &lt;code>gcc&lt;/code> compiler converts to C to ARM assembly language. We&amp;rsquo;ll specifically look at &lt;em>conditional logic&lt;/em>. We&amp;rsquo;ll look at examples of &lt;code>if&lt;/code> statements, &lt;code>if&lt;/code> statements with &lt;code>else if&lt;/code> and &lt;code>else&lt;/code>, then end with a &lt;code>switch&lt;/code> statement. To convert C to ARM assembly we will use the &lt;code>-S&lt;/code> flag on GCC. All these examples were done on a Raspberry Pi running Raspbian.&lt;/p></description></item></channel></rss>