2
<p><span class="h-card" translate="no"><a href="https://mastodon.social/@mcc" class="u-url mention">@<span>mcc</span></a></span> <span class="h-card" translate="no"><a href="https://mastodon.social/@cr1901" class="u-url mention">@<span>cr1901</span></a></span> <span class="h-card" translate="no"><a href="https://f.duriansoftware.com/@joe" class="u-url mention">@<span>joe</span></a></span> the square brackets represent an address expression, so if you do `mov rax, rcx` that&#39;s just a register move, but `mov rax, [rcx]` is a memory load from the address in rcx. in the vast majority of cases a square bracket expression is used to signify a memory operation, with lea (load effective address) being the notable exception, which loads the result of the address expression itself into the target register.</p>
<p><span class="h-card" translate="no"><a href="https://mastodon.social/@mcc" class="u-url mention">@<span>mcc</span></a></span> <span class="h-card" translate="no"><a href="https://mastodon.social/@cr1901" class="u-url mention">@<span>cr1901</span></a></span> <span class="h-card" translate="no"><a href="https://f.duriansoftware.com/@joe" class="u-url mention">@<span>joe</span></a></span> the &quot;dword&quot;, &quot;qword&quot;, etc. prefixes are generally only used for clarifying load sizes on sign extensions. for example with a regular mov, these two are equivalent:</p><p>mov eax, [eax]<br />mov eax, dword ptr [eax]</p><p>but if you do movsx, the load size is ambiguous, so you clarify it:</p><p>movsx rax, [eax] ; ambiguous (error)<br />movsx rax, word ptr [eax] ; load 16-bit<br />movsx rax, dword ptr [eax] ; load 32-bit</p>
<p><span class="h-card" translate="no"><a href="https://mastodon.social/@mcc" class="u-url mention">@<span>mcc</span></a></span> <span class="h-card" translate="no"><a href="https://mastodon.social/@cr1901" class="u-url mention">@<span>cr1901</span></a></span> <span class="h-card" translate="no"><a href="https://f.duriansoftware.com/@joe" class="u-url mention">@<span>joe</span></a></span> the &quot;normal&quot; way to express things like that in Intel syntax is [reg+disp] or [reg*scale+disp] where disp/scale are constants.</p><p>so for example if I wanted to read a dword from the address at eax multiplied by four plus 8, I&#39;d do:</p><p>mov eax, [eax*4+8]</p>
<p><span class="h-card" translate="no"><a href="https://mastodon.social/@mcc" class="u-url mention">@<span>mcc</span></a></span> i used to use intel+gas for a while</p>
<p><span class="h-card" translate="no"><a href="https://mastodon.social/@cr1901" class="u-url mention">@<span>cr1901</span></a></span> <span class="h-card" translate="no"><a href="https://f.duriansoftware.com/@joe" class="u-url mention">@<span>joe</span></a></span> By &quot;syntax&quot; I mean things like: How do I represent a literal? It appears I can type 4[r10] to mean &quot;memory address in r10 plus four bytes&quot;. Why square brackets? Where does it say you use square brackets and not some other type of brackets? Assembly language is a simple language, but it has a syntax, so I expect that syntax to be documented somewhere. If it&#39;s Intel&#39;s format I expect Intel to be the one documenting it.</p>
<p><span class="h-card" translate="no"><a href="https://mastodon.social/@cr1901" class="u-url mention">@<span>cr1901</span></a></span> <span class="h-card" translate="no"><a href="https://f.duriansoftware.com/@joe" class="u-url mention">@<span>joe</span></a></span> Say I&#39;m not programming for the 8086/8, masm, or AT&amp;T syntax. I&#39;m programming for x86_64 and I want to use Intel&#39;s syntax.</p><p>I go to <a href="https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html" target="_blank" rel="nofollow noopener" translate="no"><span class="invisible">https://www.</span><span class="ellipsis">intel.com/content/www/us/en/de</span><span class="invisible">veloper/articles/technical/intel-sdm.html</span></a> . There&#39;s a 5,000 page manual there. If the old 8086/8 datasheet defines the syntax, I&#39;d expect the 5,000 page 2024 version to as well.</p><p>I don&#39;t find it. The conventions section <a href="https://mastodon.social/@mcc/113868620088578888" target="_blank" rel="nofollow noopener" translate="no"><span class="invisible">https://</span><span class="ellipsis">mastodon.social/@mcc/113868620</span><span class="invisible">088578888</span></a> says it describes &quot;a subset of&quot; the assembly language.</p><p>Is the syntax hiding somewhere else in these 5,000 pages?</p>
<p><span class="h-card" translate="no"><a href="https://functional.cafe/@escape_velocity" class="u-url mention">@<span>escape_velocity</span></a></span> <br />Thanks, this is great.</p><p>1. Yes indeed. The author actually replied to me on Twitter to say that. I guess that&#39;s the focus of his new book.</p><p>2. I think this is caught up in the fact that social history is entirely missing. Not like the political history from rulers was accurate either, so these could also have been handled not-at-face-value.</p><p>3. Indeed, but wish it was much more. His Chola book does (he said), and I expect so does Dalrymple&#39;s /Golden Road/ (not yet in USA).</p>
<p><span class="h-card" translate="no"><a href="https://mastodon.social/@shriramk" class="u-url mention">@<span>shriramk</span></a></span> fun fact: Nandivarman II, the Pallava, was born in Vietnam (Champa desa)</p>
<p><span class="h-card" translate="no"><a href="https://mastodon.social/@mcc" class="u-url mention">@<span>mcc</span></a></span> <span class="h-card" translate="no"><a href="https://f.duriansoftware.com/@joe" class="u-url mention">@<span>joe</span></a></span> Intel&#39;s syntax goes back to the 8086/8 datasheet. You can see it in the IBM PC BIOS listings.</p><p>From there, Microsoft made their own assembler (MASM) which extends Intel&#39;s original syntax (along with all the segment shit no one cares about).</p><p>NASM is &quot;well, it&#39;s dest then source operand&quot;, like MASM, but isn&#39;t really Intel/MASM syntax either. Code written for MASM will not compile for NASM for several syntactical reasons.</p><p>And GAS/AT&amp;T syntax is the x86 Unix world. It&#39;s ass.</p>