<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Stuff and Junk &#187; assembler</title>
	<atom:link href="http://www.zanfar.com/tag/assembler/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zanfar.com</link>
	<description>The Ramblings of an OCD Engineer</description>
	<lastBuildDate>Mon, 23 Nov 2009 08:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>On the Virtues of Assembler</title>
		<link>http://www.zanfar.com/2009/the-virtues-of-assembler/</link>
		<comments>http://www.zanfar.com/2009/the-virtues-of-assembler/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 08:10:59 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Rants]]></category>
		<category><![CDATA[assembler]]></category>
		<category><![CDATA[pointers]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.zanfar.com/?p=56</guid>
		<description><![CDATA[I left the private sector in a large part because I was sick of writing code, it is ironic, although in hindsight, not surprising, that I am still surrounded by it. This situation has turned me mildly retrospective, and I&#8217;ve been trying to figure out when it was I finally got, I mean really, natively, [...]]]></description>
			<content:encoded><![CDATA[<p>I left the private sector in a large part because I was sick of writing code, it is ironic, although in hindsight, not surprising, that I am still surrounded by it. This situation has turned me mildly retrospective, and I&#8217;ve been trying to figure out when it was I finally got, I mean really, natively, understood pointers.<span id="more-56"></span></p>
<p>I&#8217;m a firm believer that the ability to play with pointers is a talent, not a skill. I don&#8217;t think it can be taught. Sure, you can lecture on it, and I can get you to pass any multiple choice, fill in the blank, &#8220;knowledge of pointers&#8221; test, but I&#8217;ve found, and <a href="http://www.joelonsoftware.com/printerFriendly/articles/GuerrillaInterviewing3.html">smarter people agree</a>, that less than half of all people are able to juggle pointer abstraction in their head. I did most of my early programming in high level languages, and never really had to deal with pointers. I understood them, but it took a few seconds on every line of code to dissect it and make sure I was using them correctly.</p>
<p>I realized last week that I get it. Totally. And I blame Assembler.</p>
<p>If you were taught Assembler well, alongside a decent CPU structure course, Assembler is all about pointers. You just don&#8217;t call them that. You&#8217;ll learn about addressing, memory locations, address registers and the Program Counter, and you&#8217;ll figure it out, because you <em>have</em> to figure it out, you can&#8217;t abstract them away, and at the end of it, without realizing it, you&#8217;ll have mastered pointers. Even the literals you use are contained in an instruction in a memory location pointed to by the Program Counter. <strong>Everything</strong> in Assembler is a pointer.</p>
<p>A lot of my peers don&#8217;t understand why I tell them, if they&#8217;re only taking a few programming courses, to take the lowest-level languages possible. This is the reason. The closer you are to the silicon, the more real examples you&#8217;ll get about why you&#8217;re told to do things a certain way. Don&#8217;t understand what&#8217;s so bad about strings? Parse one in assembler. You&#8217;ll never forget it. Why can&#8217;t you assume a flat address space? Address more than 256 bytes with an 8-bit processor in assembler, and you&#8217;ll be intimately familiar with paging and banking. Very soon you&#8217;ll realize the elegance of arrays, that they&#8217;re not just native to your language (unless you&#8217;re unlucky enough that they&#8217;re objects instead), they&#8217;re native to your processor, and the inner loop of</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>s<span style="color: #339933;">++</span> <span style="color: #339933;">=</span> <span style="color: #339933;">*</span>t<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>is probably a single CPU instruction<sup>[1]</sup>.</p>
<p>I love assembler. I get a rush when I can imagine exactly how the MCU is tossing bits around with every instruction. It&#8217;s weird, I know, but if you&#8217;re programming in any real capacity, you should love it to.</p>
<p>[1] On the 68k, it (should be) compiled to something like:</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;">strcpy<span style="color: #339933;">:</span>
  MOVE<span style="color: #339933;">.</span>b  <span style="color: #009900; font-weight: bold;">&#40;</span>A1<span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">+,</span> <span style="color: #009900; font-weight: bold;">&#40;</span>A2<span style="color: #009900; font-weight: bold;">&#41;</span><span style="color: #339933;">+</span>  <span style="color: #666666; font-style: italic;">; 14D9</span>
  CMPI<span style="color: #339933;">.</span>b  #<span style="color: #0000ff;">0</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">&#40;</span>A1<span style="color: #009900; font-weight: bold;">&#41;</span>       <span style="color: #666666; font-style: italic;">; 0C11 0000</span>
  BNE     strcpy        <span style="color: #666666; font-style: italic;">; 66F8</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.zanfar.com/2009/the-virtues-of-assembler/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
