<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Buğra Yıldız</title>
    <description>The latest articles on DEV Community by Buğra Yıldız (@mby).</description>
    <link>https://dev.to/mby</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F326667%2F4fdb63e6-63b0-4285-b385-5c43e6161258.jpg</url>
      <title>DEV Community: Buğra Yıldız</title>
      <link>https://dev.to/mby</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mby"/>
    <language>en</language>
    <item>
      <title>Basic Arithmetic in Assembly</title>
      <dc:creator>Buğra Yıldız</dc:creator>
      <pubDate>Tue, 14 Sep 2021 02:57:11 +0000</pubDate>
      <link>https://dev.to/mby/basic-arithmetic-in-assembly-3al4</link>
      <guid>https://dev.to/mby/basic-arithmetic-in-assembly-3al4</guid>
      <description>&lt;h2&gt;
  
  
  Hello there!
&lt;/h2&gt;

&lt;p&gt;So basically I just figured out how to do those 4 simple operations (adding, diving etc.) in assembly, because I need to be able to do maths in my own programming language. So here's the recap of all the pain I've been through thanks to intel:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This article is useful for people using intel x86_64 architecture with the GNU assembler, gas. You also have to use &lt;code&gt;.intel_syntax noprefix&lt;/code&gt; macro so you can use the intel syntax, which this tutorial uses.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Addition
&lt;/h2&gt;

&lt;p&gt;First things first, get your values into your 64 bit teeny tiny registers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, 1
mov rbx, 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rest is pretty simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add rax, rbx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is in &lt;code&gt;rax&lt;/code&gt;, which is &lt;code&gt;3&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Subtraction
&lt;/h2&gt;

&lt;p&gt;Same as always:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, 10
mov rbx, 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sub rax, rbx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is in &lt;code&gt;rax&lt;/code&gt;, which is &lt;code&gt;8&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Multiplication
&lt;/h2&gt;

&lt;p&gt;So, this one instruction actually has 2 ways of using it, but for the sake of simplicity, I will show you the easiest one, which is most likely erroneous because if you are writing a production ready compiler or the production code directly you HAVE TO check if multiplying two 64 bit numbers result in a 128 bit number, because if it does your result will be incorrect. But who cares right?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, 5
mov rbx, 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then a simple operation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;imul rax, rbx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Aaaanndd, the result is in &lt;code&gt;rax&lt;/code&gt;, which is &lt;code&gt;10&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Division 🤢
&lt;/h2&gt;

&lt;p&gt;So, this one is probably the messiest within the four, but here we go ladies and gentleman. This instruction takes only a single, explicit argument and an implicit argument. But using it with a little hack is pretty easy. Firstly, unlike any other instruction up until you have seen, this one requires that the dividend MUST be in the rax register.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, 100
mov rbx, 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, before diving it you have to put this instruction for some complicated reason, which affects registers &lt;code&gt;rdx&lt;/code&gt; and &lt;code&gt;rax&lt;/code&gt;. I will tell more in a minute, but just divide by then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cqo
idiv rbx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your result should be in &lt;code&gt;rax&lt;/code&gt;, and the remainder of this operation is in register &lt;code&gt;rdx&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The problem with dividing is that, because it affects other registers that you don't mention, often times when &lt;code&gt;rax&lt;/code&gt; and/or &lt;code&gt;rdx&lt;/code&gt; has values you actually  have to store them somewhere. One way to get around this is using the stack:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;note that you can put them in unused registers too!&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# store those values on the stack
push rax
push rdx

# divide
mov rax, 100
mov rbx, 5
cqo
idiv rbx

# move the result to unused registers
mov r8, rax
mov r9, rdx

# then retrieve back those values, notice the order is reverse!
pop rdx
pop rax
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I don't hate intel, but that way of dividing is uhhh... Nevertheless, this is a funny thing to know and pun your coworkers because you can do maths in ASSEMBLY now and they can't cuz they have a life and shit. Can't understand humans, see you later!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The Biggest Trade-off</title>
      <dc:creator>Buğra Yıldız</dc:creator>
      <pubDate>Mon, 15 Feb 2021 14:28:53 +0000</pubDate>
      <link>https://dev.to/mby/the-biggest-trade-off-2omd</link>
      <guid>https://dev.to/mby/the-biggest-trade-off-2omd</guid>
      <description>&lt;h1&gt;
  
  
  What is a trade-off?
&lt;/h1&gt;

&lt;p&gt;A trade-off is, in its simplest form, a choice someone makes when stuck between two beneficial facts. You sacrifice one fact to have the benefits of the other because they &lt;strong&gt;can't possibly co-exist&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In software development, we make trade-offs &lt;strong&gt;all the time&lt;/strong&gt;. They rarely ever are of great significance in terms of the program's performance, memory consumption, storage usage, etc although choosing the right one is important and usually depends on the situation. &lt;strong&gt;But&lt;/strong&gt; there are trade-offs where it is not related to the choices we make when building the software, but choices &lt;strong&gt;we can't&lt;/strong&gt; make when building it, which are of a much bigger concern to us.&lt;/p&gt;

&lt;h1&gt;
  
  
  Things we can choose.
&lt;/h1&gt;

&lt;p&gt;For example, in JavaScript instead of using &lt;code&gt;map()&lt;/code&gt; you can choose to use a regular &lt;code&gt;for&lt;/code&gt; loop where performance is critical. Or you might use a different algorithm that performs faster but uses more memory because even though you have sufficient amounts of memory you lack the processing power required to meet the demand.&lt;/p&gt;

&lt;p&gt;Such decisions are easy to make, and usually take a couple of seconds once you decide what is &lt;strong&gt;more crucial&lt;/strong&gt; in the given context. However, there are:&lt;/p&gt;

&lt;h1&gt;
  
  
  Things we &lt;strong&gt;can't&lt;/strong&gt; decide.
&lt;/h1&gt;

&lt;p&gt;For example, let's consider a simple case. You live in a 3rd world country where the internet is awful &amp;amp; hardware is expensive as specially bred utterly fluffy dogs &amp;amp; cats.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Can you run docker to learn it?&lt;/li&gt;
&lt;li&gt;Can you run Chrome with Vscode or Atom at the same time?&lt;/li&gt;
&lt;li&gt;Can you pair program with your mates whilst speaking over Discord and writing code using the great &lt;code&gt;live-share&lt;/code&gt; plugin with other extensions you may need to write good code?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Can you even use a proper operating system?&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The answer is &lt;strong&gt;no, you most likely can't&lt;/strong&gt;. You are stuck with a minimalist non-popular Linux distro that may or may not run your stuff, a Vim config which is next to nothing compared to an IDE feature-wise, and a very basic low-level compiler because interpreted languages with optimizing JIT compilation features on top with utterly broken &amp;amp; slow package managers are of a massive deal to your old crappy hardware and horrible internet. &lt;strong&gt;You sacrifice your lifespan waiting for your project to get dependencies, compile &amp;amp; run. That's the biggest trade-off.&lt;/strong&gt; Got no money for better equipment? Sacrifice a couple of hours of your life, that'll do!&lt;/p&gt;

&lt;p&gt;Evidently, you are as invaluable as bok-bags to many recruiters. Not because you lack in skill, determination, experience, and all the things that &lt;strong&gt;ARE significant&lt;/strong&gt; for software development, but because you lack in &lt;strong&gt;equipment needed&lt;/strong&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  What's the point then?
&lt;/h1&gt;

&lt;p&gt;I ask myself this, &lt;strong&gt;every damn single day.&lt;/strong&gt; What's the point in embracing software development if you can't even do the simplest &lt;code&gt;Hello World&lt;/code&gt;? Why forcefully try things that are impossible to do for you? Why?&lt;/p&gt;

&lt;p&gt;The answer is always the same, &lt;strong&gt;man do I LOVE it don't I?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes, yes, I confessed. Pun me about it and all. But &lt;strong&gt;seriously, I love it way more than I should.&lt;/strong&gt; Every day I think about it, when I wake up, whilst eating, when sleeping in my dreams. I see videos about programming in my YouTube feed, I consequently have subscribed to all the subreddits about programming because I get to have so much fun reading, watching, reasoning about them. In all of my social media accounts, there is &lt;strong&gt;at least one post&lt;/strong&gt; that I've shared my happiness with the programs I've written &amp;amp; things I have learned recently that are about programming.&lt;/p&gt;

&lt;p&gt;When all the odds are against you, and they give you only agony, seemingly massive in quantity, if you still hold on for some reason, &lt;strong&gt;that thing is called love&lt;/strong&gt;. And if you love programming, there's no going back. For everybody who doesn't have those fancy Macs, with pretty setups or fast internet (or no internet at all) access, keep holding on. Because chances are, something will happen and you &lt;strong&gt;will be&lt;/strong&gt; in the place that you have always &lt;strong&gt;dreamed &amp;amp; been longing&lt;/strong&gt; for this long. Someday all your pain will become a genuine smile into your past. You'll look back and say "what days have begone". It all will seem like a dream. A dream where you fought, and won.&lt;/p&gt;

&lt;p&gt;Keep fighting, your enemy is probably more stupid and less powerful than you think. Good luck in life,&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
