<?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>Schadenfreude &#187; assembly</title>
	<atom:link href="http://www.ralree.com/tag/assembly/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ralree.com</link>
	<description>Malicious enjoyment derived from observing someone else's misfortune</description>
	<lastBuildDate>Thu, 09 Feb 2012 01:49:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Random Fun with NASM</title>
		<link>http://www.ralree.com/2007/11/22/random-fun-with-nasm/</link>
		<comments>http://www.ralree.com/2007/11/22/random-fun-with-nasm/#comments</comments>
		<pubDate>Thu, 22 Nov 2007 03:45:00 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[assembly]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[nasm]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.ralree.info/2007/11/22/random-fun-with-nasm</guid>
		<description><![CDATA[I was on IRC tonight and someone was having trouble with their NASM homework. I decided to help them by learning NASM and coding up their homework problem for fun. It was pretty cool. I was on IRC tonight and someone was having trouble with their NASM homework. I decided to help them by learning NASM and coding up their homework problem for fun. It was pretty cool. Here&#8217;s the resultant program: ; Goal: (a+b)*c+d*b ; PARI/GP says: ; ? [...]]]></description>
			<content:encoded><![CDATA[<p>I was on IRC tonight and someone was having trouble with their NASM homework.  I decided to help them by learning NASM and coding up their homework problem for fun.  It was pretty cool.</p>
<p>            <span id="more-5031"></span></p>
<p>I was on IRC tonight and someone was having trouble with their NASM homework.  I decided to help them by learning NASM and coding up their homework problem for fun.  It was pretty cool.  Here&#8217;s the resultant program:</p>
<pre><code>
; Goal: (a+b)*c+d*b
; PARI/GP says:
; ? (1.234+5.678)*9.012+3.456*5.678
; %1 = 81.91411200000000000000000000
;
;=== Output ===
;hank@rofl:/tmp$ nasm -felf floating_point_arith.asm &#038;&#038; \
; gcc floating_point_arith.o &#038;&#038; ./a.out
;Answer: 81.91411
;===
;QED

  extern printf

  section .data
  a: dq 1.234
  b: dq 5.678
  c: dq 9.012
  d: dq 3.456
  e: dq 7.890
  fmt: db "Answer: %.5f",10,0

  section .bss
  f: resq 1

  section .text

  global main
  main:
    fldz
    fld   qword [a]
    fadd  qword [b]
    fmul  qword [c]
    fstp  qword [f]

    fld   qword [d]
    fmul  qword [b]
    fadd  qword [f]
    fstp  qword [f]

    push  dword [f+4]
    push  dword [f]
    push  dword fmt
    call  printf
    add   esp, 12
    mov   eax, 0
    ret
</code></pre>
<p>Code is also available here:</p>
<pre><code>

http://modzer0.cs.uaf.edu/repos/hank/code/asm/floating_point_arith.asm

</code></pre>
<p>All this does is add some floats and call <code>printf</code>, but it was fun to monkey around low-level again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ralree.com/2007/11/22/random-fun-with-nasm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

