Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
More Jobs
Recent
Code to detect the web browser
Base class for easy class property handling
Your average file filter...
simplify multiple gsub
Parse XML from Yahoo weather RSS feed
Base64 image encoding and image hash
Query TinyUrl the fastest way
Bencode decoder
model loader
Link to if else simple condition.
Popular
simplify multiple gsub
Code to detect the web browser
Your average file filter...
Query TinyUrl the fastest way
Base64 image encoding and image hash
Parse XML from Yahoo weather RSS feed
Base class for easy class property handling
Default value for user column
Method for sorting
Code transactions
Pastable version of
Find the max
<div style="overflow:auto;border:solid 1px #ccc;background:#000;color:#F8F8F8"> <div class="section"> <pre style="float:left;margin:0 10px;border-right:0;color:#666;">1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46</pre> <pre class="sunburst"># # Max # by Gnix <gnixmail@gmail.com> # # Example: # # [gnix@localhost <span style="color:#99CF50;">asm</span>]$ as -o max.o max.s # [gnix@localhost <span style="color:#99CF50;">asm</span>]$ ld -dynamic-linker /lib/ld-linux.so<span style="color:#3387CC;">.2</span> -o max -lc max.o # [gnix@localhost <span style="color:#99CF50;">asm</span>]$ ./max # Max = <span style="color:#3387CC;">99</span> # .section .data output: .asciz <span style="color:#65B042;"><span style="color:#65B042;">"</span>Max = <span style="color:#DDF2A4;">%d</span> <span style="color:#DDF2A4;">\n</span><span style="color:#65B042;">"</span></span> values: .<span style="color:#99CF50;">int</span> <span style="color:#3387CC;">15</span>, <span style="color:#3387CC;">23</span>, <span style="color:#3387CC;">61</span>, <span style="color:#3387CC;">35</span>, <span style="color:#3387CC;">34</span>, <span style="color:#3387CC;">21</span>, <span style="color:#3387CC;">5</span>, <span style="color:#3387CC;">99</span>, <span style="color:#3387CC;">17</span>, <span style="color:#3387CC;">52</span> .section .text .globl _start _start: movl values, %ebx # move the first element of values in EBX movl $<span style="color:#3387CC;">1</span>, %edi # insert <span style="color:#3387CC;">1</span> in EDI loop: movl values(, %edi,<span style="color:#3387CC;">4</span>), %eax # copy the values[EDI] element in EAX cmp %ebx, %eax # compare cmova %eax, %ebx # replace the value in EBX with EAX <span style="color:#E28964;">if</span> the # value is larger than what was originally # in the EBX <span style="color:#99CF50;">register</span> inc %edi # increment EDI cmp $<span style="color:#3387CC;">10</span>, %edi # compare <span style="color:#E28964;">if</span> EDI is <span style="color:#3387CC;">10</span> (number of elements) jne loop # <span style="color:#E28964;">if</span> is no <span style="color:#3387CC;">10</span> loop pushl %ebx # push the max value pushl $output # push the output string call <span style="color:#DAD085;">printf</span> # call <span style="color:#DAD085;">printf</span> addl $<span style="color:#3387CC;">8</span>, %esp # add <span style="color:#3387CC;">8</span> to the ESP (extended stack pointer) pushl $<span style="color:#3387CC;">0</span> # insert <span style="color:#3387CC;">0</span> (as <span style="color:#DAD085;">exit</span> value) call <span style="color:#DAD085;">exit</span> # call <span style="color:#DAD085;">exit</span> </pre> </div> </div> <a href="http://refactormycode.com/codes/261-find-the-max" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://refactormycode.com/images/small_logo.gif" style="border:0" /></a>