<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>funcptr - assembly</title>
    <subtitle>An engineer&#x27;s technical notebook</subtitle>
    <link rel="self" type="application/atom+xml" href="https://funcptr.net/language/assembly/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://funcptr.net/"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2008-02-03T09:59:04+00:00</updated>
    <id>https://funcptr.net/language/assembly/atom.xml</id>
    <entry xml:lang="en">
        <title>addnumbers.asm updated</title>
        <published>2008-02-03T09:59:04+00:00</published>
        <updated>2008-02-03T09:59:04+00:00</updated>
        
        <author>
          <name>
            
              Delta Regeer
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://funcptr.net/2008/addnumbers-asm-updated/"/>
        <id>https://funcptr.net/2008/addnumbers-asm-updated/</id>
        
        <content type="html" xml:base="https://funcptr.net/2008/addnumbers-asm-updated/">&lt;p&gt;If you have no clue what I am talking about, check out &lt;a href=&quot;&#x2F;2008&#x2F;introduction-to-intel-assembly&#x2F;&quot;&gt;my previous post&lt;&#x2F;a&gt;.
I have fixed the flaws, and now it will parse the commands it is handed on
the command line, and stick them into an integer. It will now print it to
stdout.&lt;&#x2F;p&gt;
&lt;p&gt;This has been an awesome learning experience for me. Especially with regards
to how to do recursion, how to debug a pure assembly program with gdb and
whatnot.&lt;&#x2F;p&gt;
&lt;p&gt;Here comes the code, as I said before, see my previous thread if you don&#x27;t
know what I am talking about, as well as instructions on how to compile the
program.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;asm&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; File: addnumbers2.asm&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Delta Regeer&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; 2008-01-27&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Function:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;;	Add numbers together that are provided as arguments to the program in argv[1] and argv[2].&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Known limitations:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;;	This will hopefully be fixed in the next revision. Floating point numbers will not work.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;;	Any input that is larger than an integer will cause overflows, and thus will not work.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;section .data&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; Define some strings that are going to be used throughout the program&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; This string is to let the user know they failed to provide the proper amount of arguments.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;args	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;db&lt;&#x2F;span&gt;&lt;span&gt;	&amp;quot;Program &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;addnumbers&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; &amp;quot;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0xa&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0x9&lt;&#x2F;span&gt;&lt;span&gt;, &amp;quot;addnumbers &amp;lt;number &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt; &amp;lt;number &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span&gt;&amp;gt;&amp;quot;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0xa&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0x9&lt;&#x2F;span&gt;&lt;span&gt;, &amp;quot;Arguments &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt; and&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 2&lt;&#x2F;span&gt;&lt;span&gt; are required.&amp;quot;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0xa&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0x9&lt;&#x2F;span&gt;&lt;span&gt;, &amp;quot;Anything that will cause addition to overflow an &lt;&#x2F;span&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;int&lt;&#x2F;span&gt;&lt;span&gt; (&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;147&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;483&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;647&lt;&#x2F;span&gt;&lt;span&gt;), will fail! :P&amp;quot;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0xa&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;largs	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;equ&lt;&#x2F;span&gt;&lt;span&gt;	$ - args&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; This string contains part of the output that we are going to send to the terminal. The last two&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; bytes will be filled automatically by the program, before it is output to stdout.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;msg	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;db&lt;&#x2F;span&gt;&lt;span&gt;	&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;Answer&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; &amp;#39;,	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;lmsg	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;equ&lt;&#x2F;span&gt;&lt;span&gt;	$ - msg&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;num1	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;dd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;	0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;num2	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;dd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;	0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;section .bss&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; This is where I am going to store the output of my conversion from an integer to a char&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;answer	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;resb&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;	64&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;section .text&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;global start				&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Linker defined entry point. Mac OS X this is start. &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;global _start				&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; FreeBSD and others _start.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;_start&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;start&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;esp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt; 		; Set up the stack frame&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ecx&lt;&#x2F;span&gt;&lt;span&gt;, [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ebp&lt;&#x2F;span&gt;&lt;span&gt; + &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span&gt;]		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Get argc, we check if it set to at least 3&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	edx&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ebp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Put the base pointer into edx, so we can use that in &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;					; our dereferences coming up&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	add&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	edx&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Add 8. We want to skip ebp and argc&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	cmp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ecx&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Check if we have at least 3 arguments to the program. &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;					; At least two arguments are required, and the 3rd one is &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;					; the name of the program&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	jl&lt;&#x2F;span&gt;&lt;span&gt;	exit			&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; If the value in ecx is less than 3, jump to exit&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esi&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Set the index to 1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;edx&lt;&#x2F;span&gt;&lt;span&gt; + &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;esi&lt;&#x2F;span&gt;&lt;span&gt; * &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span&gt;]	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Move the pointer to the character array into eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Push eax onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span&gt;	num1			&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Push the pointer to num1 onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	call&lt;&#x2F;span&gt;&lt;span&gt;	ctoi			&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Call my char to int function&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	add&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;byte&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 8&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Put the stack pointer back to where it was.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	inc&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esi&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Increase the index&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;edx&lt;&#x2F;span&gt;&lt;span&gt; + &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;esi&lt;&#x2F;span&gt;&lt;span&gt; * &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span&gt;]	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Move the pointer to the character array into eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Push eax onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span&gt;	num2			&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Push the pointer to num2 onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	call&lt;&#x2F;span&gt;&lt;span&gt;	ctoi			&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Call my char to int function&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	add&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;byte&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 8&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Put the stack pointer back to where it was.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, [num1]		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Move value stored in num1 into eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	add&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, [num2]		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Add num2 to eax, this will now be stored in eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Push the new calculated number onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	call&lt;&#x2F;span&gt;&lt;span&gt;	itoa			&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Convert the integer to a character array&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;	dword&lt;&#x2F;span&gt;&lt;span&gt; lmsg		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Push the length of the string&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span&gt;	msg			&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Push the location of the string in memory&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;	dword&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0x1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Push the file descriptor to write to&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Move the syscall number into eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Push the syscall onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	int&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;	0x80&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Interrupt 80, go to kernel&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	add&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;byte&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 16&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Clean up the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span&gt;	answer			&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Push answer onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	call&lt;&#x2F;span&gt;&lt;span&gt;	len			&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Get it&amp;#39;s length&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	edi&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Push the length onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span&gt;	answer			&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Push the pointer to the character string onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;	dword&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0x1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Push the file descriptor to write to&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Push the syscall number into eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Push the syscall onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	int&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;	0x80&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Interrupt 80, go to kernel&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	add&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;byte&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 16&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Clean up the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	jmp&lt;&#x2F;span&gt;&lt;span&gt;	done			&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Program is done. Jump to done&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;exit&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; This label is jumped to when we want to exit the program and let the user know how&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; to run the program. Like for instance what paramaters to send the program.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;				; Call sys_write&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;	dword&lt;&#x2F;span&gt;&lt;span&gt; largs		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Push the length of the string&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;	dword&lt;&#x2F;span&gt;&lt;span&gt; args		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Push the location of the string in memory&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;	dword&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0x1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Push the file descriptor to write to&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Move the syscall number into eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Push the syscall onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	int&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;	0x80&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Interrupt 80, go to kernel&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	add&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;byte&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 16&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Clean up the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;done&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; This is the label we jump to when we want to exit the program, we set the exit code&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; to 0.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;				; Call sys_exit&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;	dword&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0x0&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Push the value to return to the operating system&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Move the syscall number into eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Push the syscall onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	int&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;	0x80&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Interrupt 80, go to kernel&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; We never return to this function, so no need to clean the stack.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;ctoi&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; char to i. We actually convert entire character array&amp;#39;s to integers.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; We get two paramaters on the stack. The first one we grab is the pointer to the place to store&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; the number. The second is the pointer to the character array.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Push the old base pointer onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;esp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Create a new base pointer&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esi&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Store all the original registers&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebx&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ecx&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	edx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Push edx, so that we can overwrite it&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	sub&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; We get another storage space on the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span&gt;	[&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;esp&lt;&#x2F;span&gt;&lt;span&gt;], &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;dword&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 10&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; This is the number we are going to multiply by&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ebp&lt;&#x2F;span&gt;&lt;span&gt; + &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;12&lt;&#x2F;span&gt;&lt;span&gt;]		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Move the pointer to the character array into eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Push the pointer to the character array onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	call&lt;&#x2F;span&gt;&lt;span&gt;	len			&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Call the string length versoin&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	add&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;byte&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 4&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Reclaim the space we lost when we pushed eax onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebx&lt;&#x2F;span&gt;&lt;span&gt;, [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ebp&lt;&#x2F;span&gt;&lt;span&gt; + &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span&gt;]		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; This is where we are going to store the numbers&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esi&lt;&#x2F;span&gt;&lt;span&gt;, [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ebp&lt;&#x2F;span&gt;&lt;span&gt; + &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;12&lt;&#x2F;span&gt;&lt;span&gt;]		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; This is the pointer to the character array&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	movzx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ecx&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;di&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; move with extended zero edi.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	edi&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Clean up edi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;	ctoi_loop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ebx&lt;&#x2F;span&gt;&lt;span&gt;]		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Move the value stored in ebx into eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mul&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;	dword&lt;&#x2F;span&gt;&lt;span&gt; [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;esp&lt;&#x2F;span&gt;&lt;span&gt;]		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Move it over a 10s place.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span&gt;	[&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ebx&lt;&#x2F;span&gt;&lt;span&gt;], &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;eax&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Move the new number back into ebx&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	movzx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;byte&lt;&#x2F;span&gt;&lt;span&gt; [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;esi&lt;&#x2F;span&gt;&lt;span&gt; + &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;edi&lt;&#x2F;span&gt;&lt;span&gt;]	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Move the character into eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	movsx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;al&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; We just want the lower part of the character&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	sub&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0x30&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Subtract 0x30, ASCII 0 so that it is an actual number&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	add&lt;&#x2F;span&gt;&lt;span&gt;	[&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ebx&lt;&#x2F;span&gt;&lt;span&gt;], &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;eax&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Add the new number to the old number that has been multiplied by 10&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	inc&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	edi&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Increase the counter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	loop&lt;&#x2F;span&gt;&lt;span&gt; ctoi_loop			&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Loop into cx is 0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	add&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;byte&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 4&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	pop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	edx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Restore all the registers&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	pop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ecx&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	pop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebx&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	pop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	pop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ebp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Make esp the original base pointer again&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	pop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Pop the original base pointer into the register&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	ret&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;				; Return caller&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;itoa&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; Recursive function. This is going to convert the integer to the character.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Setup a new stack frame&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;esp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Save the registers&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebx&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ecx&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	edx&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ebp&lt;&#x2F;span&gt;&lt;span&gt; + &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span&gt;]		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; eax is going to contain the integer&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebx&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;dword&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 10&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; This is our &amp;quot;stop&amp;quot; value as well as our value to divide with&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ecx&lt;&#x2F;span&gt;&lt;span&gt;, answer		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Put a pointer to answer into ecx&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Push ebx on the field for our &amp;quot;stop&amp;quot; value&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;	itoa_loop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	cmp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ebx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Compare eax, and ebx&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	jl&lt;&#x2F;span&gt;&lt;span&gt;	itoa_unroll		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Jump if eax is less than ebx (which is 10)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	xor&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	edx&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;edx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Clear edx&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	div&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Divide by ebx (10)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	edx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Push the remainder onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	jmp&lt;&#x2F;span&gt;&lt;span&gt;	itoa_loop		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Jump back to the top of the loop&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;	itoa_unroll&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt;			&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	add&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	al&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0x30&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Add 0x30 to the bottom part of eax to make it an ASCII char&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span&gt;	[&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ecx&lt;&#x2F;span&gt;&lt;span&gt;], &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;byte&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; al&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Move the ASCII char into the memory references by ecx&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	inc&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ecx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Increment ecx&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	pop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Pop the next variable from the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	cmp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ebx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Compare if eax is ebx&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	jne&lt;&#x2F;span&gt;&lt;span&gt;	itoa_unroll		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; If they are not equal, we jump back to the unroll loop&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;				; else we are done, and we execute the next few commands&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span&gt;	[&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ecx&lt;&#x2F;span&gt;&lt;span&gt;], &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;byte&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0xa&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Add a newline character to the end of the character array&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	inc&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ecx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Increment ecx&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span&gt;	[&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ecx&lt;&#x2F;span&gt;&lt;span&gt;], &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;byte&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Add a null byte to ecx, so that when we pass it to our&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;				; len function it will properly give us a length&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	pop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	edx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Restore registers&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	pop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ecx&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	pop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebx&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	pop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ebp&lt;&#x2F;span&gt;&lt;span&gt;		&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	pop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	ret&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;len&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; Returns the length of a string. The string has to be null terminated. Otherwise this function&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; will fail miserably. &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; Upon return. edi will contain the length of the string.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Save the previous stack pointer. We restore it on return&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;esp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; We setup a new stack frame&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Save registers we are going to use. edi returns the length of the string&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; 	ecx&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ecx&lt;&#x2F;span&gt;&lt;span&gt;,  [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ebp&lt;&#x2F;span&gt;&lt;span&gt; + &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span&gt;]		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Move the pointer to eax; we want an offset of one, to jump over the return address&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	edi&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Set the counter to 0. We are going to increment this each loop&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;	len_loop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Just a quick label to jump to&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	movzx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;byte&lt;&#x2F;span&gt;&lt;span&gt; [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ecx&lt;&#x2F;span&gt;&lt;span&gt; + &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;edi&lt;&#x2F;span&gt;&lt;span&gt;]	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Move the character to eax.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	movsx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;al&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Move al to eax. al is part of eax.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	inc&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	di&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Increase di.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	cmp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Compare eax to 0.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	jnz&lt;&#x2F;span&gt;&lt;span&gt; 	len_loop		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; If it is not zero, we jump back to len_loop and repeat.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	dec&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	di&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Remove one from the count&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	pop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ecx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Restore registers&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	pop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ebp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Set esp back to what ebp used to be.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	pop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Restore the stack frame&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	ret&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;				; Return to caller&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Introduction to Intel Assembly</title>
        <published>2008-01-27T03:42:44+00:00</published>
        <updated>2008-01-27T03:42:44+00:00</updated>
        
        <author>
          <name>
            
              Delta Regeer
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://funcptr.net/2008/introduction-to-intel-assembly/"/>
        <id>https://funcptr.net/2008/introduction-to-intel-assembly/</id>
        
        <content type="html" xml:base="https://funcptr.net/2008/introduction-to-intel-assembly/">&lt;p&gt;This semester I am taking a class on Intel assembly, because I want more of an
insight into how the computer works, and it will allow me to better reverse
engineer new viruses and spyware. The class is also required if one is a
Software Engineering major, so that means I have to take it.&lt;&#x2F;p&gt;
&lt;p&gt;We had our first assignment. Sum two numbers and then output them to the
screen. We were supposed to write inline assembly using Visual Studio C++,
but if we are to do an assembly class, then we should learn how to write
assembly, not have some parts assembly and other parts the compiler. Sure
it makes it easy as you will get immediate access to the standard C
library, but if you want that, you can just link against it.&lt;&#x2F;p&gt;
&lt;p&gt;The following code examples were written on Mac OS X, and will work on
FreeBSD. Linux uses a different calling convention for its syscalls, and as
such this code will not run on Linux, unless it is modified. Do note, you
need an Intel Mac for this to work. This is Intel assembly.&lt;&#x2F;p&gt;
&lt;p&gt;Compile the code with (Mac OS X):&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;nasm&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; macho addnumbers.asm&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;ld&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -o&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; addnumbers addnumbers.o&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;or (FreeBSD):&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;nasm&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; elf addnumbers.asm&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;ld&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; -o&lt;&#x2F;span&gt;&lt;span style=&quot;color: #ECC48D;&quot;&gt; addnumbers addnumbers.o&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Then you can run it with:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;.&#x2F;addnumbers&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 1 5&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;As you can see in the comments of the source code, there are still some
limitations, but the rest of the source code should be made readable by the
comments that are provided.&lt;&#x2F;p&gt;
&lt;p&gt;Porting to Linux: Please double check that all the syscall numbers are the
same. There are some differences between Linux and FreeBSD&#x2F;Mac OS X in that
regard.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #D6DEEB; background-color: #011627;&quot;&gt;&lt;code data-lang=&quot;asm&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; File: addnumbers.asm&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Delta Regeer&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; 2008-01-27&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Function:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;;	Add numbers together that are provided as arguments to the program in argv[1] and argv[2].&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Known limitations:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;;	As of right now, the numbers that are provided may not add up to anything more than 9.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;;	This will hopefully be fixed in the next revision. Floating point numbers will not work.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Todo:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;;	Write conversion routine, to convert a string of numbers into a real integer on which&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;;	math may be performed.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;section .data&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; Define some strings that are going to be used throughout the program&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; This string is to let the user know they failed to provide the proper amount of arguments.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;args	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;db&lt;&#x2F;span&gt;&lt;span&gt;	&amp;quot;You failed to provide the proper amount of arguments&amp;quot;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0xa&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;largs	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;equ&lt;&#x2F;span&gt;&lt;span&gt;	$ - args&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; This string contains part of the output that we are going to send to the terminal. The last two&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; bytes will be filled automatically by the program, before it is output to stdout.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;msg	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;db&lt;&#x2F;span&gt;&lt;span&gt;	&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;Answer&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; &amp;#39;,	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;,	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;lmsg	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C5E478;&quot;&gt;equ&lt;&#x2F;span&gt;&lt;span&gt;	$ - msg&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;section .text&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;global start				&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Linker defined entry point. Mac OS X this is start. FreeBSD and others _start.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;global _start&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;_start&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;start&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Start the program here.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	add&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;byte&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 8&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; We don&amp;#39;t care about argc or argv[0]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	pop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt; 	ecx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Get the first argument or argv[1]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	jecxz&lt;&#x2F;span&gt;&lt;span&gt;	exit			&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; If there was no argument. Exit. Let the user know why&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; Change the number from a character to an actual dword&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;dword&lt;&#x2F;span&gt;&lt;span&gt; [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ecx&lt;&#x2F;span&gt;&lt;span&gt;]	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Move the character into eax so we can manipulate it&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	sub&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0x30&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Remove 0x30 from the character. To make it an actual number, not an ASCII number.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	pop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ecx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; get the second argument or argv[2]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	jecxz&lt;&#x2F;span&gt;&lt;span&gt;	exit			&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; If there was no second argument. Exit. Let the user know why&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebx&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;dword&lt;&#x2F;span&gt;&lt;span&gt; [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ecx&lt;&#x2F;span&gt;&lt;span&gt;]	&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Move the character into ebx so we can manipulate it&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	sub&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	ebx&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0x30&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Remove 0x30 from the character. To make it an actual number, not an ASCII number.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	add&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;ebx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Add the two numbers together&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	add&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;0x30&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Make it an ASCII number again&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span&gt;	[msg+lmsg-&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span&gt;], &lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;eax&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; Replace the null character in the msg with the answer&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span&gt;	[msg+lmsg-&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;], &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;dword&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0xa&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; Add an newline character so that when it spits it out it is neatly formatted&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;				&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;				; Call sys_write&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;	dword&lt;&#x2F;span&gt;&lt;span&gt; lmsg		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Push the length of the string&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span&gt;	msg			&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Push the location of the string in memory&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;	dword&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0x1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Push the file descriptor to write to&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Move the syscall number into eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Push the syscall onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	int&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;	0x80&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Interrupt 80, go to kernel&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	add&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;byte&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 16&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Advance the stack pointer&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	jmp&lt;&#x2F;span&gt;&lt;span&gt;	done			&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Program is done. Jump to done&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;exit&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;				; Call sys_write&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;	dword&lt;&#x2F;span&gt;&lt;span&gt; largs		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Push the length of the string&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;	dword&lt;&#x2F;span&gt;&lt;span&gt; args		&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;; Push the location of the string in memory&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;	dword&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0x1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Push the file descriptor to write to&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Move the syscall number into eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Push the syscall onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	int&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;	0x80&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Interrupt 80, go to kernel&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	add&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	esp&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;byte&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 16&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Advance esp past the part we were just at&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #82AAFF;font-style: italic;&quot;&gt;done&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;				; sys_exit&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C792EA;&quot;&gt;	dword&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt; 0x1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;		; Push the value to return to the operating system&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	mov&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Move the syscall number into eax&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #82AAFF;&quot;&gt;	eax&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Push the syscall onto the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #7FDBCA;&quot;&gt;	int&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F78C6C;&quot;&gt;	0x80&lt;&#x2F;span&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;			; Interrupt 80, go to kernel&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #637777;font-style: italic;&quot;&gt;	; We never return to this function, so no need to clean the stack.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;</content>
        
    </entry>
</feed>
