<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>coding tutorials Archives - NeuralLantern.com</title>
	<atom:link href="https://www.NeuralLantern.com/tag/coding-tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.NeuralLantern.com/tag/coding-tutorials/</link>
	<description></description>
	<lastBuildDate>Sun, 14 Sep 2025 23:46:12 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.NeuralLantern.com/wp-content/uploads/2025/04/cropped-2025-04-04-Lantern-03-32x32.png</url>
	<title>coding tutorials Archives - NeuralLantern.com</title>
	<link>https://www.NeuralLantern.com/tag/coding-tutorials/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Command Line Arguments in Yasm Assembly with GCC: A Practical Guide</title>
		<link>https://www.NeuralLantern.com/command-line-arguments-in-yasm-assembly-with-gcc-a-practical-guide/</link>
					<comments>https://www.NeuralLantern.com/command-line-arguments-in-yasm-assembly-with-gcc-a-practical-guide/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sun, 14 Sep 2025 23:46:11 +0000</pubDate>
				<category><![CDATA[Assembly Language]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[argv argc]]></category>
		<category><![CDATA[assembly programming]]></category>
		<category><![CDATA[coding tutorials]]></category>
		<category><![CDATA[command line args]]></category>
		<category><![CDATA[command line arguments]]></category>
		<category><![CDATA[GCC assembly]]></category>
		<category><![CDATA[GCC linking]]></category>
		<category><![CDATA[hybrid programming]]></category>
		<category><![CDATA[low-level programming]]></category>
		<category><![CDATA[programming guide]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[x86 assembly]]></category>
		<category><![CDATA[x86-64 programming]]></category>
		<category><![CDATA[Yasm assembly]]></category>
		<category><![CDATA[Yasm tutorial]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=227</guid>

					<description><![CDATA[<p>Learn to process command line arguments in Yasm assembly with GCC. Practical x86-64 guide for hybrid programs with clear examples. #Assembly #Programming</p>
<p>The post <a href="https://www.NeuralLantern.com/command-line-arguments-in-yasm-assembly-with-gcc-a-practical-guide/">Command Line Arguments in Yasm Assembly with GCC: A Practical Guide</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Command Line Arguments in Yasm Assembly with GCC: A Practical Guide" width="1380" height="776" src="https://www.youtube.com/embed/r5K10mL2OPE?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Want to master command line arguments in Yasm assembly? This video breaks down how to access and process args in x86-64 hybrid programs linked with GCC. From understanding argv and argc to looping through arguments, we cover it all with practical examples. Perfect for programmers diving into assembly or looking to level up their low-level coding skills. Check out my other videos for more on Yasm and pure assembly! Subscribe for more coding tutorials. #AssemblyProgramming #YasmAssembly #GCC #x86_64</p>



<p>Introduction 00:00:00<br>Command Line Arguments Overview 00:00:03<br>Yasm Assembly and GCC Linking 00:00:07<br>Hybrid Program Explanation 00:01:27<br>Makefile Overview 00:02:16<br>Assembly Program Structure 00:03:16<br>Main Entry Point and Registers 00:03:51<br>Accessing Command Line Arguments 00:04:26<br>Argument Count and Pointers 00:05:03<br>Loop Initialization for Arguments 00:08:57<br>Loop Logic and Dereferencing 00:10:52<br>Printing Arguments 00:13:02<br>Incrementing Pointers in Loop 00:14:08<br>Running the Program 00:15:35<br>Practical Application of Arguments 00:17:24<br>Conclusion and Next Steps 00:17:51<br>Call to Subscribe and Outro 00:18:22</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p>Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Hello there. In this video,</p>



<p>I&#8217;m going to talk to you about how to accept incoming command line arguments to</p>



<p>an x86-64 Yasm assembly program that is probably linking to</p>



<p>GCC and is thus probably a hybrid program under the hood.</p>



<p>If you don&#8217;t know how to program in Yasm assembly yet,</p>



<p>check out my other videos. If you don&#8217;t understand command line arguments yet,</p>



<p>yet check my other videos I&#8217;m going to assume a lot of knowledge here I&#8217;m</p>



<p>really just going to show you how to pull the arguments inside of assembly</p>



<p>using using the GCC setup that they&#8217;ve given you so just a quick just a very</p>



<p>quick recap this is not a command line arguments video if we have the program</p>



<p>echo and we give it like one argument of just the word hello then it&#8217;s it&#8217;s</p>



<p>going to receive one command line argument in addition to its program</p>



<p>echo as argument zero and hello as argument index one.</p>



<p>And it&#8217;s just going to be able to look at them and say,</p>



<p>oh, the user wants me to print this hello string.</p>



<p>So it just prints it.</p>



<p>And so that&#8217;s kind of how you can tell a program what to do,</p>



<p>either when you&#8217;re running them directly</p>



<p>or having one program automate another program.</p>



<p>Anyway, so in our Yasm assembly programs,</p>



<p>how do we actually get that out?</p>



<p>Well, for starters, we are dynamically linking.</p>



<p>Sorry, not dynamically linking.</p>



<p>We are linking a hybrid program.</p>



<p>So I just want to make sure that you understand this is the right video for you.</p>



<p>If you&#8217;re trying to do this in pure assembly, or if you need to know that for some reason,</p>



<p>then you&#8217;ll probably want to watch the next video that I publish.</p>



<p>But for now, this is a hybrid program.</p>



<p>Hybrid programs, for those of you who don&#8217;t know, it just means you have modules that</p>



<p>are written in different source code and they&#8217;re compiled differently, different source code</p>



<p>languages.</p>



<p>So you might have a source code file that&#8217;s written in C++ another one that&#8217;s written in C another one that&#8217;s written in assembly</p>



<p>And you compile them all down to their own object files and then you link them together into an executable</p>



<p>If GCC is part of the linking process</p>



<p>Then it&#8217;s going to end up giving you a main function as your entry point and it&#8217;s going to make things a little bit easier</p>



<p>Here&#8217;s my make file. I&#8217;m just going to skim through it real fast. This is not a make file video</p>



<p>So if you don&#8217;t understand it go look at my other videos</p>



<p>But basically I&#8217;m just going to assemble with Yasm and I&#8217;m going to use G++ as the linker</p>



<p>and I&#8217;m going to gobble up all of the object files. Here&#8217;s like a little menu.</p>



<p>I have a target for running and building only. And here&#8217;s the main thing that I&#8217;m doing. This</p>



<p>is not really a hybrid program. This is just kind of a pure assembly program that is linked with GCC,</p>



<p>but you can imagine you could add other source files in C and C++ and still totally get away</p>



<p>GCC. But anyway, I&#8217;m just compiling one source code of assembly and,</p>



<p>and compiling it down to an object file right here.</p>



<p>And then when it comes time to linking, uh, you can kind of tell here, uh,</p>



<p>especially if you&#8217;re familiar with make files that I&#8217;m just gobbling up all the</p>



<p>object files and linking them together into the executable.</p>



<p>So that&#8217;s as far as I&#8217;ll go there again,</p>



<p>I&#8217;ve got another video that totally explains a lot more in my assembly program.</p>



<p>video just for pure assembly so if you don&#8217;t understand assembly see my other videos but for</p>



<p>now we&#8217;re just going to say i&#8217;ve got a data section it&#8217;s got a couple of null terminated strings we&#8217;ve</p>



<p>got a hello message a begin message a goodbye message carriage return line feed string i&#8217;ve</p>



<p>got the system call codes for you know printing to standard output and to exit the program and then</p>



<p>i&#8217;ve got the standard output file handle and then my exit code zero for success again this is all</p>



<p>other videos. So because I&#8217;m linking with GCC, my text section here, the actual place where the</p>



<p>instructions are, not the data, is going to have a main entry point. So of course, if you had a</p>



<p>hybrid program, you could have main somewhere else in a different module and then just call on a</p>



<p>function that was inside of assembly. You could totally do that. But for now, I&#8217;m just going to</p>



<p>say this is the only source code file. So I mark main as global and I put main right here. And then</p>



<p>I preserve all of the Kali saved registers that I&#8217;m supposed to by pushing them at the beginning and popping them in reverse order at the end.</p>



<p>And then I return a return value.</p>



<p>Standard assembly stuff covered in other videos.</p>



<p>But here&#8217;s the key for getting command line arguments in assembly.</p>



<p>If you recall, the ABI specifies that in x86-64 programs, the first argument is always supposed to come into a function as RDI in the RDI register.</p>



<p>register or rather I should say the first integer argument I haven&#8217;t talked</p>



<p>about to float arguments in any of my videos yet in the future you should</p>



<p>probably search for other videos that that explain how to do float arguments</p>



<p>but for now all of the arguments I&#8217;m talking about in this video are just</p>



<p>integer arguments and pointer arguments which is kind of the same thing a</p>



<p>pointer is an integer it&#8217;s a 64-bit integer but we&#8217;ll just use it as a</p>



<p>using it as an integer so anyway first argument comes in on RDI second argument</p>



<p>comes in on RSI and you can imagine that basically this is the thing you&#8217;re</p>



<p>probably used to seeing in your C++ programs if we do this int main and then</p>



<p>integer arg C and then a character pointer arg V and then an array those are</p>



<p>those two registers right there I probably want to change this into long</p>



<p>because you know rdi is in 64-bit form but an integer is an unsigned 32-bit int.</p>



<p>I don&#8217;t like that so I&#8217;m just going to put long. I probably should put unsigned but I don&#8217;t really</p>



<p>care. Anyway so we&#8217;re just going to grab those two things so obviously rdi is probably pretty</p>



<p>easy for you to guess how to use it&#8217;s just the number of arguments. In this program we&#8217;re going</p>



<p>to use it to control a loop counter that&#8217;s going to loop through all incoming arguments.</p>



<p>which is going to be the name of the program in this case it&#8217;ll be I think</p>



<p>just main is what I called it which is confusing against the entry point I</p>



<p>admit it but imagine that my main program that sits in the file system is</p>



<p>actually called program or hello or whatever so that&#8217;s the number of</p>



<p>arguments in RDI and then RSI notice how it&#8217;s a character pointer to an array of</p>



<p>characters that means it&#8217;s actually a pointer to a pointer and the reason for</p>



<p>every argument on the command line like for instance if i went back here and i said echo</p>



<p>hello let&#8217;s just do without quotes hello you i&#8217;ve given it two arguments and so when the program</p>



<p>launches it&#8217;s going to receive three total it&#8217;s going to receive its own program name at index zero</p>



<p>echo it&#8217;s going to receive at index one the first argument hello and it&#8217;s going to receive at index</p>



<p>two the second argument as you it prints them both so how does echo know how many arguments i have</p>



<p>strings. Remember argc is the number of arguments so that&#8217;s kind of easy but how does it dereference</p>



<p>all of the strings if there could be any number of strings? Well that&#8217;s this right here.</p>



<p>This whole symbol argv is a pointer and it points to an array of pointers, of character</p>



<p>pointers. That&#8217;s why it&#8217;s written like this like an array. So it&#8217;s a pointer that points</p>



<p>points to an array.</p>



<p>So like if you go to that location in memory,</p>



<p>then what you will see there for the first eight bytes</p>



<p>is just the address of some other memory location where a string has been stored.</p>



<p>Then if you advance that pointer another eight bytes for it,</p>



<p>you know, in memory, because all pointers are eight bytes or 64 bits,</p>



<p>then again, you&#8217;ll see that that value of that next eight bytes</p>



<p>is actually a memory location that points to another string somewhere else.</p>



<p>So these strings could be all over the place,</p>



<p>But the pointers to those strings are contiguous in memory starting with what you were given in RSI.</p>



<p>So it&#8217;s a character pointer pointer or an array of character pointers, however you want to imagine that.</p>



<p>Anyway, so we&#8217;ll grab those and then I&#8217;ll just show you how to use them down further in the code.</p>



<p>For starters, I&#8217;m calling on an intro function which just basically prints some stuff.</p>



<p>I have a custom function that I wrote called print null terminated string.</p>



<p>That&#8217;s not the point of this video.</p>



<p>I have that explained in other videos a little bit.</p>



<p>So it&#8217;s up to you if you want to even care.</p>



<p>Right now I just want to be able to print something.</p>



<p>And then let&#8217;s see.</p>



<p>So after we print our welcome message in the intro, then we print another message basically</p>



<p>saying okay now we&#8217;re about to start printing all the arguments.</p>



<p>Okay cool.</p>



<p>Nothing complicated at this point.</p>



<p>Then I have another label here with my preferred style of adding a suffix after the function</p>



<p>after the function that I&#8217;m currently inside of.</p>



<p>And I&#8217;m going to say, all right, this is where I initialize my loop.</p>



<p>This is not a looping video, so I&#8217;m going to skim through it kind of.</p>



<p>But I&#8217;m basically going to say, let&#8217;s start the loop as basically saying</p>



<p>the index of the argument that we&#8217;re currently looking at is zero</p>



<p>because we&#8217;ll start with zero.</p>



<p>So that means we&#8217;ll print like if we were going to, if our program was named Echo,</p>



<p>we would also print Echo itself and not just all the incoming arguments</p>



<p>that the user might have typed.</p>



<p>index zero and then we&#8217;re going to use r15 as the current character pointer so r15 its current</p>



<p>character pointer is going to be coming from r13 which was the argv argument so that means</p>



<p>r15 is now going to hold a pointer uh let&#8217;s see it&#8217;s going to hold</p>



<p>when you have an array and the array is contiguous in memory then the pointer itself that points to</p>



<p>the array is also a pointer to the first item that&#8217;s just kind of the way it works like if we</p>



<p>have 10 items and it&#8217;s an array then your pointer to that array is also a pointer to the first item</p>



<p>in the array if that makes sense so if r13 was a pointer to an array it&#8217;s also a pointer to the</p>



<p>go off to a null terminated string i know that sounds weird you got to get used to double dereferencing</p>



<p>here so all we really need to do to access uh the first pointer to the actual string is take the</p>



<p>array pointer that we have and dereference it one time so remember we&#8217;re receiving an argv</p>



<p>a pointer to a pointer or like a you know a double pointer if we dereference it once then we should</p>



<p>terminated string. Anyway, so that&#8217;s the initialization part. I&#8217;m going to start looking</p>



<p>at the first string here and I&#8217;m going to say we&#8217;re at index zero. And then here&#8217;s the top of</p>



<p>my loop. You can imagine this is a while loop. This is not a while video, but you know, there it is.</p>



<p>And we&#8217;re just going to ask first, are we actually done? Do we need to break the loop? I like to do</p>



<p>that at the top of my while loop. And how we&#8217;ll do that is we&#8217;ll say, all right, R14 is the index</p>



<p>the number of arguments so notice how like right here we grabbed RDI right</p>



<p>into R12 right away so basically I&#8217;m saying if the index we&#8217;re currently</p>



<p>looking at is greater than or equal to the number of arguments then we&#8217;re</p>



<p>actually already done remember if we&#8217;re using zero based indexing and you</p>



<p>suppose that you have three items in your array their indexes would be zero</p>



<p>So that means if the size of your array is three, like the count, like the RFC, that</p>



<p>means the last valid index is two.</p>



<p>It&#8217;s one less than the size.</p>



<p>You know, it&#8217;s one less than the count.</p>



<p>So I&#8217;m saying at this point that if we ever reach an index number that is equal to the</p>



<p>size, then we&#8217;ve already finished.</p>



<p>We do not need to look at the current item.</p>



<p>So I&#8217;m comparing those two registers.</p>



<p>You know, where are we looking at versus what is the count?</p>



<p>You know, what is the index we&#8217;re looking at versus the count?</p>



<p>If the index we&#8217;re looking at is greater than or equal to the count, then that means we&#8217;re done.</p>



<p>I&#8217;m going to jump out of the loop to a label called main loop done.</p>



<p>So then, you know, that&#8217;s down here.</p>



<p>Basically, we just say goodbye and then we jump to our exit function.</p>



<p>And all that does is it just returns from main with some kind of a success code.</p>



<p>You know, so just you can imagine in C++, it&#8217;s just return zero.</p>



<p>So, you know, breaking the loop doesn&#8217;t really do anything except end the program and say goodbye.</p>



<p>However, if we did not jump, then the, let&#8217;s see if we did not jump, let&#8217;s, let&#8217;s see if</p>



<p>we did jump, we compared it, we realized that we&#8217;re done.</p>



<p>Then it&#8217;s going to jump down to the, to the done.</p>



<p>But if we&#8217;re not done, execution is going to fall through to the next statement.</p>



<p>So that means we&#8217;re going to end up doing something with the current item inside of</p>



<p>our loop.</p>



<p>So what are we going to do?</p>



<p>We&#8217;re going to dereference R15.</p>



<p>was your pointer to a pointer it was your double pointer there if we dereference it once then</p>



<p>instead of being a pointer to an array of pointers it&#8217;s going to be a pointer to one string one one</p>



<p>character that starts one string so dereferencing it once means you know i put brackets around the</p>



<p>double pointer it&#8217;s now dereferenced once that means rdi is going to receive a pointer to one</p>



<p>into my function my function takes two arguments it wants a pointer to a string and it wants</p>



<p>the file descriptor to print to again other videos explain you know printing to standard</p>



<p>output but i&#8217;m just going to print the string so this part right here should actually print</p>



<p>the argument and then after we&#8217;re done with that uh well maybe i should change this</p>



<p>so that it&#8217;s a little bit more clear i&#8217;m going to maybe push this down and say</p>



<p>these lines up here actually do something they do the printing by</p>



<p>dereferencing and then here we just sort of increment along the array of pointers</p>



<p>and jump back to the top of the loop so what are we doing here with r14</p>



<p>remember r14 was the index that we&#8217;re currently looking at so we we start</p>



<p>looking at index 0 line 83 is going to say let&#8217;s next look at index 1 and then</p>



<p>this part right here add 8 to r15 that just basically means remember r15 was</p>



<p>remember r15 was the double pointer the double pointer like i said before it&#8217;s looking at an</p>



<p>array of pointers so it&#8217;s actually a pointer to a pointer if i increase the memory location that</p>



<p>r15 holds then it&#8217;s now looking at the next pointer it&#8217;s moving through the array r15 at</p>



<p>that point would no longer be a valid pointer to the original array it&#8217;s sort of like a running</p>



<p>pointer it&#8217;s kind of like scanning all of the pointers but a pointer is eight bytes so if we&#8217;re</p>



<p>a pointer is eight bytes so if we&#8217;re just looking at the first pointer and we increase the memory</p>



<p>location that we&#8217;re looking at by eight bytes now we&#8217;re looking at the second pointer so then on the</p>



<p>next iteration of the loop if we dereference then we&#8217;re going to end up dereferencing to the second</p>



<p>string then i just print a little new line here honestly probably should have put that up top</p>



<p>sloppy code i was doing this quickly and then we jump to the top of the loop so then we just</p>



<p>going up to the top of the loop and printing arguments and advancing to the</p>



<p>next pointer. And we just keep going at it.</p>



<p>Let me see if this works. Hopefully I didn&#8217;t mess this up while I was screwing</p>



<p>around. All right. So I&#8217;m going to do this make run. Okay.</p>



<p>So under the hood inside of my make file,</p>



<p>maybe let&#8217;s open the make file real fast just so you can see.</p>



<p>I&#8217;m just going to nano it real fast here under the hood.</p>



<p>So when I call the program to run, notice how I&#8217;m giving it arguments.</p>



<p>You can see right here on this line, or actually let me get the line numbers up.</p>



<p>You can see on line 48, I am calling my executable, which is named main.</p>



<p>In the make file, I&#8217;m using a variable, so don&#8217;t worry about that.</p>



<p>But I&#8217;m giving it four arguments.</p>



<p>And I&#8217;m just saying first arg, second arg, third arg, fourth arg.</p>



<p>So that&#8217;s why you see that printed in the previous screen.</p>



<p>screen it&#8217;s just going through all the arguments that I gave it it&#8217;s saying</p>



<p>first arg second arg third arg fourth arg notice how it knows when to stop</p>



<p>because of the argc that came in on RDI now that the program is built you know</p>



<p>I&#8217;ve got my main executable which I named main which I said before was kind</p>



<p>of confusing now that I&#8217;ve got it I can just execute it again and give it like</p>



<p>one argument of like hello notice how it prints hello on a line by itself you do</p>



<p>do it again dudes and notice how every argument I give it it just prints it no</p>



<p>matter how many I do I can go a b c d e f g I could probably do this so many</p>



<p>times that I exhaust you know a long integer which is would be a horrible</p>



<p>endeavor but yeah everything that I put on there it just loops through it and</p>



<p>prints it so when you are linking with GCC because you&#8217;re probably using a</p>



<p>if you&#8217;re just linking with GCC.</p>



<p>GCC makes it really, really easy</p>



<p>to access the command line arguments.</p>



<p>Imagine now instead of just printing these things,</p>



<p>you used them to somehow decide</p>



<p>what your program was gonna do.</p>



<p>Maybe the user will give you a sub command.</p>



<p>Like if you&#8217;re a Git user, we say Git status, right?</p>



<p>So the Git says like, oh, you Git launches</p>



<p>and it goes, you want the status of something?</p>



<p>Yeah, sure.</p>



<p>So in your program now,</p>



<p>you could read what the user typed,</p>



<p>figure out a way to parse it and interpret it</p>



<p>have your program&#8217;s behavior adjust to whatever the user typed in okay that&#8217;s it for this video</p>



<p>the next video I&#8217;m going to post is how to do basically exactly the same thing but using pure</p>



<p>assembly without linking against GCC so like LD is going to be the linker just like pure assembly</p>



<p>no extra libraries okay thank you so much for watching this video I hope you learned a little</p>



<p>tell your friends and i&#8217;ll see you in the next video</p>



<p>hey everybody thanks for watching this video again from the bottom of my heart i really appreciate it</p>



<p>i do hope you did learn something and have some fun uh if you could do me a please a small little</p>



<p>favor could you please subscribe and follow this channel or these videos or whatever it is you do</p>



<p>on the current social media website that you&#8217;re looking at right now it would really mean the</p>



<p>and grow this community so we&#8217;ll be able to do more videos, longer videos, better videos,</p>



<p>or just I&#8217;ll be able to keep making videos in general. So please do me a kindness and subscribe.</p>



<p>You know, sometimes I&#8217;m sleeping in the middle of the night and I just wake up because I know</p>



<p>somebody subscribed or followed. It just wakes me up and I get filled with joy. That&#8217;s exactly</p>



<p>what happens every single time. So you could do it as a nice favor to me or you could troll me if</p>



<p>you want to just wake me up in the middle of the night, just subscribe and then I&#8217;ll just wake up.</p>



<p>just wake up I promise that&#8217;s what will happen also if you look at the middle of</p>



<p>the screen right now you should see a QR code which you can scan in order to go</p>



<p>to the website which I think is also named somewhere at the bottom of this</p>



<p>video and it&#8217;ll take you to my main website where you can just kind of like</p>



<p>see all the videos I published and the services and tutorials and things that I</p>



<p>offer and all that good stuff and if you have a suggestion for clarifications or</p>



<p>or errata or just future videos that you want to see please leave a comment or if you just want to</p>



<p>say hey what&#8217;s up what&#8217;s going on you know just send me a comment whatever i also wake up for</p>



<p>those in the middle of the night i get i wake up in a cold sweat and i&#8217;m like it would really it</p>



<p>really mean the world to me i would really appreciate it so again thank you so much for</p>



<p>watching this video and um enjoy the cool music as as i fade into the darkness which is coming for us</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/command-line-arguments-in-yasm-assembly-with-gcc-a-practical-guide/">Command Line Arguments in Yasm Assembly with GCC: A Practical Guide</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/command-line-arguments-in-yasm-assembly-with-gcc-a-practical-guide/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Mastering System Services in x86-64 Assembly Programming</title>
		<link>https://www.NeuralLantern.com/mastering-system-services-in-x86-64-assembly-programming/</link>
					<comments>https://www.NeuralLantern.com/mastering-system-services-in-x86-64-assembly-programming/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Mon, 18 Aug 2025 14:42:23 +0000</pubDate>
				<category><![CDATA[Assembly Language]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[assembly language]]></category>
		<category><![CDATA[assembly programming]]></category>
		<category><![CDATA[coding tutorials]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[exit codes]]></category>
		<category><![CDATA[file descriptors]]></category>
		<category><![CDATA[file operations]]></category>
		<category><![CDATA[low-level programming]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[standard output]]></category>
		<category><![CDATA[syscalls]]></category>
		<category><![CDATA[system calls]]></category>
		<category><![CDATA[system services]]></category>
		<category><![CDATA[x86-64 assembly]]></category>
		<category><![CDATA[Yasm assembly]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=205</guid>

					<description><![CDATA[<p>Learn x86-64 assembly system services! Master syscalls, file descriptors, and program exits with clear examples in this coding tutorial. #AssemblyProgramming</p>
<p>The post <a href="https://www.NeuralLantern.com/mastering-system-services-in-x86-64-assembly-programming/">Mastering System Services in x86-64 Assembly Programming</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Mastering System Services in x86-64 Assembly Programming" width="1380" height="776" src="https://www.youtube.com/embed/-ukGDzRNTxU?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Ready to master x86-64 assembly? This video breaks down system services, showing you how to use syscalls to print messages, handle file descriptors, and exit programs cleanly. We’ll walk through a real assembly program, explain key concepts like standard output and file handles, and share tips from a top book on the subject. Whether you’re new to assembly or sharpening your skills, this tutorial is packed with clear examples and practical advice. Subscribe for more coding deep dives, and check out our upcoming file I/O video! #AssemblyProgramming #SystemCalls #x86_64 #CodingTutorials</p>



<p>Introduction to System Services 00:00:00<br>System Services in x86-64 Assembly 00:00:04<br>Recommended Book on Assembly 00:00:35<br>What is a System Service? 00:01:01<br>Example Assembly Program 00:01:21<br>Syscall Instruction Explanation 00:02:52<br>Standard Output and File Descriptors 00:04:01<br>Printing a String with Syscall 00:05:16<br>Exiting a Program with Syscall 00:07:21<br>Exit Codes and Program Success 00:08:02<br>Book Reference for System Services 00:09:51<br>Detailed System Write Service 00:11:01<br>Checking System Call Return Values 00:12:08<br>File Operations with System Calls 00:14:35<br>Closing Files and Best Practices 00:15:50<br>Other System Call Codes 00:16:43<br>File Permissions and Modes 00:17:20<br>Handling System Call Results 00:19:03<br>Future Video Plans and Wrap-Up 00:20:40<br>Call to Subscribe and Outro 00:21:28</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p>Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Hey everybody in this video we&#8217;re going to talk a little bit about system services</p>



<p>in an x86-64 machine while programming in assembly</p>



<p>this video is going to focus on yasm assembly but this should also work for any other assembly</p>



<p>language that you program as long as you have the right kind of cpu x86-64 is also known as</p>



<p>that in mind okay so for starters let&#8217;s see here&#8217;s a wonderful book i love pushing this book i did</p>



<p>not write it the person who wrote it is a genius it&#8217;s called x86 64 assembly language programming</p>



<p>with the boot to it&#8217;s a free and open source book so anybody can go get it find his website</p>



<p>and here&#8217;s the version i&#8217;m using and honestly a really old version of this book is still really</p>



<p>good he just keeps you know making little improvements but it was it was good even a</p>



<p>even a long time ago. Anyway, so what is a system service? For starters, before I go into this book</p>



<p>a little bit more, what is the system service? Suppose for the sake of argument that I&#8217;ve</p>



<p>already written an assembly program, a pure assembly program, not a hybrid module program</p>



<p>or anything. If you want to learn assembly, see my other videos, but for now I&#8217;m just going to</p>



<p>assume you kind of already know how, so I&#8217;m just going to open up a pre-made program here.</p>



<p>I&#8217;m going to do nano so I can edit the assembly file just so you can see what&#8217;s inside of here.</p>



<p>just so you can see what&#8217;s inside of here.</p>



<p>Okay, so I hope the red is not too hard to see.</p>



<p>Oh, the tabs got ruined on Nano.</p>



<p>Hang on, let me see if I can just open this up in Genie.</p>



<p>Should have done that to begin with, okay.</p>



<p>Yeah, okay, I wrote it in Genie</p>



<p>and I guess I don&#8217;t have the tabs set up in Nano very well.</p>



<p>Okay, so here&#8217;s like my assembly program.</p>



<p>You know, I just have a little string here</p>



<p>string length and CRLF for like a line feed and some file descriptors and stuff</p>



<p>that I talk about in other videos here&#8217;s the entry point of the program just like</p>



<p>a little start entry point because it&#8217;s pure assembly and all I&#8217;m gonna do is</p>



<p>I&#8217;m gonna print a message right I&#8217;m just gonna print a little hello message and</p>



<p>then call on CRLF all CRLF does is just it just prints a new line so the program</p>



<p>if i run it right now you&#8217;ll just see what happens if i say let&#8217;s see clear and make run</p>



<p>then you can see there&#8217;s some stuff happening up here in the make file which i forgot to update</p>



<p>the title ignore that basically the real action is this line right here hello i&#8217;m printing using</p>



<p>a system service if you already know assembly then you have probably already seen this before</p>



<p>and it seems a little boring that&#8217;s good but i just want you to know that we&#8217;re using a system</p>



<p>system service to actually do the printing.</p>



<p>Kind of take it for granted here.</p>



<p>This little instruction called syscall.</p>



<p>What is a syscall?</p>



<p>Well, it&#8217;s just basically you set up some variables, some,</p>



<p>some codes, some data, whatever in, in some special registers.</p>



<p>One of the registers lets the system know what you want it to do.</p>



<p>One of the registers is like, or I guess all the following registers</p>



<p>if they&#8217;re needed, are just input to the system call that you&#8217;re trying to do.</p>



<p>do so in this case rax is letting the system know i want you to do this this code i want you to do</p>



<p>this certain thing i have a defined set up here called system right but if you look up in my</p>



<p>little defines area it&#8217;s just a number one so that means if i set the number one in rax i&#8217;m letting</p>



<p>the system know that i want it to write to some pipe to some file then you know depending on what</p>



<p>code you&#8217;re using rdi rsi rdx and other things may be needed or maybe not be needed at all</p>



<p>in this case when i&#8217;m writing somewhere it wants three arguments so i have to use rdi rsi and rdx</p>



<p>because those are the three arguments the first argument that it wants is where to print</p>



<p>see my other videos for a more in-depth explanation of file descriptors and pipes but just long story</p>



<p>pipes standard input standard output and standard error standard out is a pipe</p>



<p>number one let&#8217;s see where&#8217;s that yeah it&#8217;s just assigned a number one so</p>



<p>every program has its own number one pipe which is just standard output and I</p>



<p>guess I should say that it gets piped to file descriptor one it&#8217;s kind of like an</p>



<p>ambiguous term sort of but the system right call will write data to a file</p>



<p>file and if i give it a file handle of just one that lets the system know oh actually i want to</p>



<p>write to this standard output for the one particular process that we&#8217;re inside of but</p>



<p>you could open any file that you want and get like a file handle to it and the operating system will</p>



<p>realize oh you know i i associate that file handle i gave you with this certain open file that you</p>



<p>created or opened for reading or whatever um and so when you give the handle back it knows where</p>



<p>knows where to write. So in this case,</p>



<p>it&#8217;s treating the standard output just like a file,</p>



<p>just a file with a special handle of just one.</p>



<p>I&#8217;ll talk about that more in another video.</p>



<p>Then the next two arguments it wants is just the,</p>



<p>a pointer to the first character of the message that you want to print.</p>



<p>And then just an integer representing the length of the message that you want</p>



<p>to print. And if we just look up here again at my little hello,</p>



<p>my hello symbol points to an array of bytes, just characters.</p>



<p>bytes just characters there is no null terminator on there it&#8217;s just bytes only</p>



<p>and so when I give it you know message hello by itself what I&#8217;m really giving</p>



<p>it is a pointer to that H letter just a pointer to the memory look you know I&#8217;m</p>



<p>pointing to the memory location of the very first character in that string and</p>



<p>then for the length I&#8217;m just using a special token little shortcut thing</p>



<p>where you just put a dollar sign minus and then the name of another string and</p>



<p>and then the name of another string,</p>



<p>and then the assembler will compute the length of that string.</p>



<p>So this right here is the same thing as me</p>



<p>just typing the exact length of the string.</p>



<p>I don&#8217;t even know what it is.</p>



<p>I don&#8217;t feel like counting it.</p>



<p>You can at home if you want.</p>



<p>One, two, three, four, I&#8217;m not gonna do it.</p>



<p>Anyway, so we basically just say,</p>



<p>you know, I would like to write somewhere.</p>



<p>I would like to write to the standard output file,</p>



<p>file handle, I would like to, you know, to that pipe.</p>



<p>I would like to write, you know, this string,</p>



<p>you know this string and then i would like to tell you that this is how long that string is</p>



<p>and then after you set all that stuff up you just say system call and the system will go ahead and</p>



<p>do all of the hard work for you it&#8217;ll go figure out how to actually write data to the file and</p>



<p>you know figure out how to do everything that it&#8217;s supposed to do and all you have to do is</p>



<p>a little system call here right after this you can see that i have a call crlf that&#8217;s just a function</p>



<p>call i talked about functions in other videos but basically you know i&#8217;m just calling a function here</p>



<p>you know i&#8217;m just calling a function here and it does the same thing it makes a system call but</p>



<p>instead of printing the hello string it&#8217;s printing my crlf string and if you just kind of look at what</p>



<p>my crlf is it&#8217;s just these two characters 13 and 10 so like you know slash r slash n for carriage</p>



<p>return line feed that&#8217;s why i call it crlf so all this program does just print a message and then a</p>



<p>new line and then at the very end it does another system call to properly exit the program if this</p>



<p>hybrid program and I had like the entry point of main, you know, that the GCC libraries give you,</p>



<p>then I would probably just want to return at the end of this function. But since this is pure</p>



<p>assembly, I can actually just exit the program and be fine. So exit with success is a different</p>



<p>system call code. Notice how I have the symbol system exit loaded into RAX. And if you look up</p>



<p>here, system exit is just the code 60. So if I send a code of one into RAX, that means I want to write</p>



<p>a code of 60 somewhere that means i want to exit the program the only argument that takes is rdi</p>



<p>which is just what is the exit code that you want to return to the operating system so um</p>



<p>if you recall from some of my other videos let&#8217;s see if we do echo hello echo always succeeds at</p>



<p>least as far as i know there&#8217;s like it&#8217;s like really hard to make it fail if i echo hello then</p>



<p>the program echo launches and it will succeed by just printing the word hello like see how it just</p>



<p>like see how it just does that so that means after that command i could echo the special</p>



<p>variable dollar sign question mark just to see what the echo command exited with right it should</p>



<p>be a zero because it succeeded so you can see now a zero under the hello on the other hand</p>



<p>if i concatenate um let&#8217;s say a file that exists i should also get you know an error code that is a</p>



<p>So it&#8217;s a zero at the very end.</p>



<p>But if I try to concatenate a file that doesn&#8217;t actually exist,</p>



<p>I&#8217;ll put a OS release two because that doesn&#8217;t exist.</p>



<p>Notice how the cat command fails because it couldn&#8217;t find the file and the exit</p>



<p>code is a one.</p>



<p>So all you&#8217;re doing when setting RDI here is just controlling what exit code you</p>



<p>want your program to exit with.</p>



<p>This isn&#8217;t very convenient for a human running a program.</p>



<p>Maybe if you want to look at the exit code for some reason, but this is really,</p>



<p>really convenient for programs that want to automate other programs.</p>



<p>programs just keep in mind if you have a program that is executing another</p>



<p>program and it wants to see if that program succeeded the exit code is one</p>



<p>of the easiest ways to find out if the program succeeded so this is the whole</p>



<p>idea of this entire program we&#8217;re just using two system calls to print</p>



<p>something and then to exit the program hopefully this makes sense and now I</p>



<p>want to go show you this wonderful wonderful book if I didn&#8217;t already say</p>



<p>If I didn&#8217;t already say this before, sorry if I already did.</p>



<p>This book is written by a genius.</p>



<p>It&#8217;s called this.</p>



<p>Here&#8217;s the guy who wrote the book.</p>



<p>And here&#8217;s the version that I&#8217;m using, but old versions are good.</p>



<p>You can get this book for free on his website if you go find it.</p>



<p>So I&#8217;m just going to go to this assembly book, which deals with a lot of Yasm assembly tips</p>



<p>and tricks and tutorials and explanations and things.</p>



<p>And I&#8217;m going to go to the section labeled after system services.</p>



<p>So for me, this is a chapter 13 system services, just to give you a little explanation of what</p>



<p>this is.</p>



<p>You know, this is basically what I said.</p>



<p>It gives you, you know, a chance for your application to ask the operating system to</p>



<p>do something for you that you don&#8217;t want to program from scratch in assembly or that you</p>



<p>can&#8217;t program.</p>



<p>But here&#8217;s the real juicy details here.</p>



<p>If we go to, yeah, yeah.</p>



<p>Okay.</p>



<p>C, which is section 23.0 system services.</p>



<p>There&#8217;s a whole bunch of system services in here that you can, uh, that you can read about.</p>



<p>So for starters, if we go down a little bit, notice how it says basic system services.</p>



<p>If we go down a little bit, you can see right here, the system write service that we&#8217;ve</p>



<p>been using in the sample assembly program.</p>



<p>You know, when we&#8217;re just printing, we say code one is to write something.</p>



<p>And so this is what the table says.</p>



<p>you place inside of RAX before syscall.</p>



<p>Call code 1 is going to be to write characters and then it tells you what arguments it needs.</p>



<p>So like RDI is the file descriptor where do you want to write to.</p>



<p>Just like I said before you could give it a file handle that you already received from</p>



<p>opening a file or creating a file.</p>



<p>Or you could give it 0 or 1 or 2 if you want to try to write to one of the pipes although</p>



<p>actually file descriptor 0 is standard input I don&#8217;t think that would actually work.</p>



<p>zero to reading if you wanted to read the user&#8217;s input or or you know any input that that program</p>



<p>was given through its standard input rsi is just the address of the characters to write like we</p>



<p>talked about before and then rdx is the count of the characters to write notice how there are no</p>



<p>more arguments and that&#8217;s why i only gave it three arguments besides rex notice how it says here if</p>



<p>unsuccessful it returns a negative value if successful it returns the count of characters</p>



<p>count of characters actually written this is a really really good idea if you think about it</p>



<p>um a lot of new programmers they don&#8217;t really look at return codes when they call system services</p>



<p>or built-in c functions or built-in c++ functions they just kind of call it and hope for the best</p>



<p>but imagine if you uh if you try to write a huge long string in uh using system write call code one</p>



<p>and maybe some of the characters did write but the system decided to only write i don&#8217;t know half for</p>



<p>reason maybe it ran out of buffer maybe you know it interrupted you know your right or something</p>



<p>like that so it could happen what that would mean is that the return value it would be greater than</p>



<p>zero indicating that some characters were written but it&#8217;ll tell you exactly how many characters</p>



<p>were written so you&#8217;ll know that you got to keep calling the sys call until all the characters were</p>



<p>successfully written why would you do this i don&#8217;t know maybe you have a gigantic string like maybe</p>



<p>like a several gigabyte file and you wanted to copy it to another file so you&#8217;ll be calling</p>



<p>system write over and over again and system write it&#8217;s only going to write so many bytes at the same</p>



<p>time so you use the return value to figure out how far forward in the read buffer you need to advance</p>



<p>or you know whatever so that you can well write the entire complete file or the entire complete</p>



<p>string or whatever it is without any gaps without it being truncated and so forth and then of course</p>



<p>And then of course, if it returns a negative value, then it totally failed.</p>



<p>Like you tried to write to a bad file handle, like standard input or a file handle that</p>



<p>was closed or a file handle that was open for reading only, something like that.</p>



<p>And then you can use some if else, you know, branching logic.</p>



<p>I mean, not if else in assembly, it&#8217;s just going to be comparison and conditional jumping</p>



<p>or branching.</p>



<p>But you can have more control over your program, right?</p>



<p>Because you want your program to be able to respond to errors.</p>



<p>Let me just quickly cruise through all of the other options and let you know that</p>



<p>and let you know that in another video I&#8217;m gonna do a full tutorial for how to</p>



<p>copy one file to another by opening one file for reading and then like using</p>



<p>system calls to read from it and then open another file for writing and then</p>



<p>you know use system calls to write to it and I&#8217;m gonna do that looping buffer</p>



<p>stuff that I talked about before anyway so but for now I&#8217;m just gonna go through</p>



<p>the rest of these system call codes let&#8217;s see so first off we got open well</p>



<p>Well, if you want to open a file, then you just give it call code 2 and you pass in the</p>



<p>address here, you know, RDI, you say, here&#8217;s the address of a null terminated file name.</p>



<p>So that means somewhere in memory, you have to have the file name that you want to open</p>



<p>with a null terminator, like a zero at the end of the string, either the full path or</p>



<p>relative path to wherever the program is currently running.</p>



<p>And then RSI is going to be file status flags.</p>



<p>And what does that mean?</p>



<p>And what does that mean? We can actually just search for that.</p>



<p>I&#8217;m going to say control C to copy,</p>



<p>and then I&#8217;m going to do control F to search for that.</p>



<p>And let&#8217;s see what page of mine right now, 340.</p>



<p>If I go down to the search results for that,</p>



<p>it just explains what the file modes are. So if you put value zero,</p>



<p>that means read only you&#8217;re opening the file and read only mode value one.</p>



<p>That means a write only a value to allows reading and writing to the file.</p>



<p>So if you don&#8217;t know what that means, well, there it was.</p>



<p>What was I just on before?</p>



<p>40?</p>



<p>Oh, gosh.</p>



<p>Completely lost my…</p>



<p>Oh, yeah, 40.</p>



<p>Okay, so opening pretty easy, right?</p>



<p>Like if you didn&#8217;t know this before, you didn&#8217;t necessarily read me.</p>



<p>You could just look at this table and go, what do I want to do?</p>



<p>I want to open.</p>



<p>So here&#8217;s the code.</p>



<p>Here&#8217;s the address that it needs.</p>



<p>When you&#8217;re done opening a file, when you&#8217;re done working with a file,</p>



<p>you want to close that file unless the whole program is going to terminate.</p>



<p>unless the whole program is going to terminate at that point you i mean maybe you have a function</p>



<p>that gets called somewhat often and you kind of always have to open a file and sort of look at</p>



<p>something or write something and maybe you want to close it when the function is over right you</p>



<p>don&#8217;t want to have a file handle just open forever that&#8217;s a waste of memory and it might introduce</p>



<p>bad behavior to your program if you just have a bunch of file handles floating around that you</p>



<p>forgot about so it&#8217;s proper to close a file when you&#8217;re finished with it that&#8217;s just going to be</p>



<p>and it only wants one argument.</p>



<p>It just wants the file descriptor of the file that you wanted to close.</p>



<p>So if you open a file for a reading or to create it,</p>



<p>you get a file descriptor back.</p>



<p>You should probably hang on to it somewhere on the stack</p>



<p>or like in a global variable or like, you know, in a register or whatever.</p>



<p>Then when you&#8217;re done doing something to that file</p>



<p>and you&#8217;re sure that it&#8217;s time to close it,</p>



<p>just give that handle right back when you call code three to close it.</p>



<p>Then you can sort of like seek, you know,</p>



<p>forward and backwards to the file if you want to.</p>



<p>You can fork the current process.</p>



<p>You can fork the current process that&#8217;s kind of advanced for this video.</p>



<p>You can exit.</p>



<p>Remember before we exited from that program with code 60.</p>



<p>So that&#8217;s it. Call code 60.</p>



<p>If you didn&#8217;t watch this video, you could have gone through this table and just said,</p>



<p>Oh, you know, I want to terminate the executing process.</p>



<p>I do a system call with code 60 and I&#8217;ll give the exit status to RDI,</p>



<p>which is typically zero for success.</p>



<p>Bunch of other stuffs create, get the time of day,</p>



<p>and then the file modes that we talked about before.</p>



<p>we talked about before and then file permissions. Let&#8217;s see, where&#8217;s the permission. I think it&#8217;s</p>



<p>when you want to create a file. Yeah, right here. If we wanted to create a file, that&#8217;s code 85.</p>



<p>RDI is the name of the file, you know, like a pointer to the string. RSI is the file mode flags.</p>



<p>And then you&#8217;re thinking like, what are the file mode flags? Just go down here and then here you</p>



<p>go. All the file modes that you could ever want. You just look at it and go, well, I guess I can</p>



<p>I guess I can just copy paste this number right here and it&#8217;ll end up being, you know,</p>



<p>whatever is described on the left and the right.</p>



<p>Like the group has read, write and execute permissions and so forth.</p>



<p>I mean, really, if you look at this long enough, you&#8217;ll kind of realize that this is a quad</p>



<p>word because it has a Q on the end of it.</p>



<p>And the rest is just an octal file permissions notation where this first number here, notice</p>



<p>how the first two are zeros, but this first actual number here is something that applies</p>



<p>to the user and then the next one applies to the group the next one applies to others who are not</p>



<p>part of the user or group and this video is not about file permissions I&#8217;ll probably make one</p>



<p>later if I think people will actually watch it but yeah you can just kind of like look it up here if</p>



<p>you want to and just copy paste that into a define somewhere let&#8217;s see what else I just want to show</p>



<p>you a little code snip just to illustrate a little bit more what I was talking about before</p>



<p>for. People usually make this mistake, they&#8217;ll do see this is what people will usually do like new</p>



<p>programmers. Suppose this is a function pretend we&#8217;re in C or C++. For the time being, you call</p>



<p>some sort of a system function or an API of some other library. And you just you just hope that it</p>



<p>works, you just call it and then your program continues underneath, right? It&#8217;s a bad idea,</p>



<p>because maybe that failed, maybe there&#8217;s some action you need to take. So instead, it&#8217;s a really</p>



<p>really good idea to check the return result or i should say an even better idea is check the</p>



<p>documentation usually these types of you know c system calls or function calls or api calls or</p>



<p>whatever they&#8217;ll return something indicating success or failure sometimes the documentation</p>



<p>will tell you oh you&#8217;ve got to put like a pointer to some other data structure in the arguments</p>



<p>and then the result comes there of course just read the documentation but usually it&#8217;s just</p>



<p>So you want to grab the result and then check the result.</p>



<p>In this case I&#8217;m assuming this is sort of a standard function that will return zero</p>



<p>or greater on success like the system write call or the system read call and return less</p>



<p>than zero if it fails.</p>



<p>So here I&#8217;m just responding, you know, if it&#8217;s like if the result was greater than zero</p>



<p>then it&#8217;s like, yay we can proceed.</p>



<p>Maybe I&#8217;ll continue with my program in some way and if it&#8217;s not then I&#8217;ll print a complaint</p>



<p>then I&#8217;ll print a complaint to the user and then I&#8217;ll take some sort of an action</p>



<p>like I&#8217;ll write to a log file, send an email somewhere, you know,</p>



<p>do something to try and recover from the error and alert admins to the error.</p>



<p>And in this case, I&#8217;m just throwing an exception.</p>



<p>This video is not about exceptions, but so I just want you to know,</p>



<p>this is a good design pattern to not just discard the result of a call to</p>



<p>something. You should check the result and see what you&#8217;re supposed to do.</p>



<p>Let&#8217;s see, what else did I want to tip?</p>



<p>system services, file handles.</p>



<p>Yeah, okay, I think that&#8217;s everything that I wanted to tell you.</p>



<p>In future videos, I&#8217;m going to talk about, you know, some of this stuff much more in-depth,</p>



<p>like with my file.io video that I&#8217;m going to publish pretty soon, which is, you know,</p>



<p>it lets you read and write to files, and it uses a loop to read a little bit at a time.</p>



<p>Okay, thank you so much for watching this video.</p>



<p>I hope you learned a little bit of stuff and had a little bit of fun.</p>



<p>I&#8217;m outie.</p>



<p>Or something.</p>



<p>Goodbye.</p>



<p>you&#8217;re looking at right now it would really mean the world to me and it&#8217;ll</p>



<p>help make more videos and grow this community so we&#8217;ll be able to do more</p>



<p>videos longer videos better videos or just I&#8217;ll be able to keep making videos</p>



<p>in general so please do do me a kindness and and subscribe you know sometimes</p>



<p>I&#8217;m sleeping in the middle of the night and I just wake up because I know</p>



<p>somebody subscribed or followed it just wakes me up and I get filled with joy</p>



<p>that&#8217;s exactly what happens every single time so you could do it as a nice favor</p>



<p>could you control me if you want to just wake me up in the middle of the night</p>



<p>just subscribe and then I&#8217;ll just wake up I promise that&#8217;s what will happen</p>



<p>also if you look at the middle of the screen right now you should see a QR</p>



<p>code which you can scan in order to go to the website which I think is also</p>



<p>named somewhere at the bottom of this video and it&#8217;ll take you to my main</p>



<p>website where you can just kind of like see all the videos I published and the</p>



<p>services and tutorials and things that I offer and all that good stuff and if</p>



<p>if you have a suggestion for uh uh clarifications or errata or just future videos that you want to</p>



<p>see please leave a comment or if you just want to say hey what&#8217;s up what&#8217;s going on you know just</p>



<p>send me a comment whatever i also wake up for those in the middle of the night i get i wake</p>



<p>up in a cold sweat and i&#8217;m like it would really it really mean the world to me i would really</p>



<p>appreciate it so again thank you so much for watching this video and um enjoy the cool music</p>



<p>as I fade into the darkness which is coming for us all.</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/mastering-system-services-in-x86-64-assembly-programming/">Mastering System Services in x86-64 Assembly Programming</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/mastering-system-services-in-x86-64-assembly-programming/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How Linkers Work: Linking Code, Virtual Memory, and Module Jumps Explained</title>
		<link>https://www.NeuralLantern.com/how-linkers-work-linking-code-virtual-memory-and-module-jumps-explained/</link>
					<comments>https://www.NeuralLantern.com/how-linkers-work-linking-code-virtual-memory-and-module-jumps-explained/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Mon, 02 Jun 2025 13:04:50 +0000</pubDate>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[assembly programming]]></category>
		<category><![CDATA[C++ programming]]></category>
		<category><![CDATA[code linking]]></category>
		<category><![CDATA[coding tutorials]]></category>
		<category><![CDATA[compilation]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[executable files]]></category>
		<category><![CDATA[jump instructions]]></category>
		<category><![CDATA[linker]]></category>
		<category><![CDATA[module linking]]></category>
		<category><![CDATA[object files]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[programming basics]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[virtual memory]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=139</guid>

					<description><![CDATA[<p>Learn how linkers connect code modules, manage virtual memory, and handle jumps in this beginner-friendly guide to programming! #Linker #Coding</p>
<p>The post <a href="https://www.NeuralLantern.com/how-linkers-work-linking-code-virtual-memory-and-module-jumps-explained/">How Linkers Work: Linking Code, Virtual Memory, and Module Jumps Explained</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="How Linkers Work: Linking Code, Virtual Memory, and Module Jumps Explained" width="1380" height="776" src="https://www.youtube.com/embed/Q6B9FWCeaFs?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Hey everyone, let’s talk linkers! In this video, we unpack the general idea of linking in programming—taking your source code, turning it into object files, and stitching them into an executable. We dive into virtual memory, how programs use offsets, and why jump instructions matter across modules. Using simple assembly and C++ examples, we’ll show how linkers lay out modules, handle labels, and make function calls work. Whether you’re a beginner or a coder curious about what happens under the hood, this is for you! Hit subscribe, scan the QR code for more tutorials, and drop a comment with your thoughts or video ideas. Let’s keep learning and have some fun with code! #Programming #Linker #VirtualMemory #CodingExplained</p>



<p>Introduction to Linking 00:00:00<br>Compilation and Object Files 00:00:05<br>Linker Overview 00:00:32<br>Virtual Memory Explanation 00:00:42<br>Program Memory Offsets 00:01:18<br>Jump Instructions in Modules 00:02:54<br>Module Address Space 00:03:38<br>Assembler and Label Jumps 00:04:02<br>Linker’s Role in Module Layout 00:07:15<br>Function Calls Across Modules 00:08:04<br>Marking Labels as Global 00:09:31<br>External Function Calls 00:10:23<br>Data in Executables 00:11:12<br>Conclusion and Call to Subscribe 00:12:08</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p>Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Hey there, I want to talk to you very quickly about the general idea of linking your programs.</p>



<p>In previous videos I&#8217;ve described exactly how to perform the linking stage when you&#8217;re compiling</p>



<p>a program. So you write some source code, you compile the source code into object files,</p>



<p>you know each file becomes one individual object file, and then when we&#8217;re done we take all the</p>



<p>object files and we link them up into an executable program. So I&#8217;ve talked about that</p>



<p>I just wanted to talk to you about the general idea of the linking stage in general.</p>



<p>Like what is the linker? What is its job? What is it actually doing?</p>



<p>So try to keep in mind for starters, each program uses virtual memory.</p>



<p>It uses a virtual memory space.</p>



<p>So obviously on your computer you have real memory,</p>



<p>but there&#8217;s lots of layers of abstraction between the physical hardware</p>



<p>the physical hardware and the program that&#8217;s running for starters the operating system uses</p>



<p>a paging system the memory stick the memory circuitry might be doing something else for</p>



<p>error checking or just you know transport or whatever so so try and bear in mind that each</p>



<p>program thinks that it&#8217;s it thinks that itself is kind of the beginning of memory you could imagine</p>



<p>it as each program thinks that its first memory location that it has assigned to it is memory</p>



<p>location zero but that wouldn&#8217;t necessarily be the case on the computer</p>



<p>your operating system probably would have come up with an offset let&#8217;s say</p>



<p>for example you know your computer decides to launch your program it</p>



<p>creates a process it finds a chunk of memory that&#8217;s available across you know</p>



<p>one or more pages of free memory and let&#8217;s say for the sake of argument that</p>



<p>the starting offset for the for the quote-unquote real forgetting the other</p>



<p>layers layers of abstraction the real memory location of your program is going</p>



<p>of your program is going to be let&#8217;s just say like a thousand I know that&#8217;s</p>



<p>real unrealistically too low but let&#8217;s just say a thousand and then let&#8217;s say</p>



<p>that your program then thinks that it starts at memory location zero that</p>



<p>means if your program wants to access memory location 100 then under the hood</p>



<p>at the last moment right before you actually hit the RAM stick or hit the</p>



<p>page file system a translation has to be performed so if your program is trying</p>



<p>what actually happens is you know the general offset for the entire program</p>



<p>gets added to memory location 100 and then that tells the computer or the</p>



<p>operating system that what you&#8217;re actually trying to do in your program is</p>



<p>access memory location 1100 so keep in mind all of this memory is virtual</p>



<p>and the modules themselves also need to know where to jump when I say where to</p>



<p>Well, suppose for the sake of argument, you have a program that has some jump instructions</p>



<p>or go to instructions or like some conditional branching instructions, anything where execution</p>



<p>is not just going to go to the very next statement.</p>



<p>Execution is going to go somewhere else.</p>



<p>Like maybe you have an if else block.</p>



<p>It&#8217;s got to maybe jump sometimes down to the else part instead of the top if part.</p>



<p>And then when it&#8217;s done executing, it&#8217;s going to jump until after the whole block, you know,</p>



<p>There will be lots of times in all of your programs where execution kind of has to jump</p>



<p>around somewhere if the program is even a little bit complicated.</p>



<p>So that could be a jump instruction, go to in a higher level language, not assembly necessarily,</p>



<p>jump if not equal and so forth.</p>



<p>So if you imagine writing one module, you could also imagine that the module has its</p>



<p>own virtual memory address space.</p>



<p>Just imagine it for now.</p>



<p>And maybe it starts at zero.</p>



<p>at zero that&#8217;s that&#8217;s not what we&#8217;re going to say but just like imagine the module only really knows</p>



<p>about itself and so sometimes when you&#8217;re jumping for example if we&#8217;re going to jump uh when</p>



<p>something is not equal to something else we&#8217;ll jump to some label and in order to jump to that</p>



<p>label the assembler needs to know you know where is that label inside of your source code so pretend</p>



<p>just for a moment this is not like a real assembly program but just pretend for a moment that we have</p>



<p>and maybe this is like I don&#8217;t know the main label that gets jumped into from GCC and</p>



<p>so then we have like a label down here outside and we&#8217;ll do stuff and then jump back to the</p>



<p>original point so we probably have to do a label here main finish this is this is bad form but I&#8217;m</p>



<p>So if we jump, let&#8217;s compare, I don&#8217;t know, one with two or something.</p>



<p>Let&#8217;s compare RAX to RDX and we&#8217;ll just move RAX the value one and move RDX the value two</p>



<p>so they&#8217;re not actually equal.</p>



<p>And then we compare them and then we say, all right, jump if they&#8217;re not equal to this label.</p>



<p>So definitely now we know, oh, we are going to jump down to that label.</p>



<p>So execution is going to go directly down to here.</p>



<p>we&#8217;ll do something and then eventually maybe we want to jump back so we&#8217;ll say uh</p>



<p>maybe let&#8217;s do it again let&#8217;s do let&#8217;s do like a whole set of statements again we&#8217;ll say jump</p>



<p>if it is equal and we&#8217;ll just like load those two registers so one and one and then compare</p>



<p>them and then say jump if it is equal to main finish this is not a video about conditional</p>



<p>branching or jumping i&#8217;m trying to make this as simple as i can but i hope you understand the</p>



<p>but i hope you understand the point is just basically we&#8217;re jumping around within the same</p>



<p>module right so it&#8217;s easy for the program to understand where to jump if it&#8217;s in the same</p>



<p>module or i guess the the object file when we&#8217;re assembling it it&#8217;s easy to understand where to jump</p>



<p>because if we&#8217;re at line 8 here when we start to jump and then the actual label here has its first</p>



<p>instruction at line 17 well then it you know the amount of instructions to move is just the</p>



<p>the difference you know so it&#8217;s easy to say all right if our virtual address is you know this</p>



<p>when we jump and we&#8217;re going to jump this much of a difference based on where the label is then now</p>



<p>we can just compute the new virtual address to jump or the absolute address or whatever you want</p>



<p>to whatever you want to do on that particular run but how does it know where to jump in another</p>



<p>module because when we assemble this module as an object file the assembler is only running one pass</p>



<p>one pass on just this object file it doesn&#8217;t really know the addresses in the other modules</p>



<p>it doesn&#8217;t know their offsets of its labels even if it&#8217;s a c plus plus or a c module it doesn&#8217;t</p>



<p>really know the offsets it doesn&#8217;t know where the functions start and end doesn&#8217;t know anything</p>



<p>because right now if we assemble this one source code it&#8217;s only going to know about this one source</p>



<p>code right and the same goes for the other modules if we compile a c plus plus program to an object</p>



<p>a function or you know do a go to statement or something into one of these labels from this</p>



<p>module the c plus plus program won&#8217;t really know where it is it won&#8217;t know what address it&#8217;s at it</p>



<p>won&#8217;t know the offset right so that&#8217;s the job of the linker the linker looks at all of these labels</p>



<p>and all of these uh conditional branching statements and jump statements and everything</p>



<p>and it just decides for starters it decides where each module is going to start in memory so maybe</p>



<p>I don&#8217;t know if your C++ module starts up here somewhere and then it&#8217;ll say this assembly module</p>



<p>starts right after it and then another module right after that and it&#8217;ll just kind of decide</p>



<p>where every module will start in the final executable that we&#8217;re actually linking together.</p>



<p>Once it decides the layout then it knows the offset of all the different modules and therefore</p>



<p>it can compute the additional offset that it would take to get to all the labels. So then at that</p>



<p>Your C++ module will make a function call inside of, you know, some assembly module like the one we&#8217;re looking at, assuming it was written a little bit differently.</p>



<p>Main finish return.</p>



<p>I guess the way it&#8217;s written down here, it&#8217;s returning to main if we just kind of execute it as we&#8217;re looking at it.</p>



<p>But another module could could call main finish as a function and still get a return statement.</p>



<p>That would actually work, even though it&#8217;s probably bad design.</p>



<p>that your assembly sorry your C++ program wants to call a function called</p>



<p>main finish inside of this module the linker having already laid out the</p>



<p>modules and and being aware of all their offsets it knows okay so you know this</p>



<p>assembly module it was underneath the C++ module so it&#8217;ll just take that offset</p>



<p>and add it to the offset of the label itself within the module and then also</p>



<p>add that to the the virtual address or I guess the operating system will do the</p>



<p>address. But you know, the point is the linker coordinates all the jumps and the conditional</p>



<p>branches where the functions start, lays out all the modules, gets all the offsets,</p>



<p>and then starts replacing all of the conditional branches and jumps and things with the real</p>



<p>offsets that make it actually doable. Like let&#8217;s jump to exactly this memory location</p>



<p>in code exactly in quotes, because we&#8217;re still using virtual addressing.</p>



<p>idea of the linker it knows how to jump between modules um wants to link or discuss okay that&#8217;s</p>



<p>all i really wanted to say don&#8217;t forget if you want a label to be available to jump into or to</p>



<p>call as a function from outside the module you got to mark it as global so if i actually wanted</p>



<p>somebody to be able to call main finish as a function i just have to mark it as global same</p>



<p>thing for some label if i say global some label then now at this point another module could call</p>



<p>call this as a function or jump into it probably bad form to not put a return a return statement</p>



<p>at this point which means when i&#8217;m calling it up here instead of jump not equal to i probably have</p>



<p>to add more complicated logic so i can use a function call that gets jumped around if it is</p>



<p>equal but so i&#8217;m not going to go that far right now kind of complicated just for this video</p>



<p>and then also of course if you intend to jump somewhere else remember that you have to mark</p>



<p>So let&#8217;s say there&#8217;s a function in your other module, your C++ module or your C module or your assembly module.</p>



<p>You just have to mark it as extern in the text section, in the text segment, like some other function somewhere else, something like that.</p>



<p>And then once I do that, now I could actually call it, I could say, call, you know, this.</p>



<p>Actually, that&#8217;ll never get reached because the jump equal thing is at the bottom.</p>



<p>equal thing is at the bottom but I could do this I could say call it if it was actually a function</p>



<p>or I could say jump if it was just a jump point or I could say you know jump not equal to</p>



<p>the other function instead of some label something like that so lots of stuff you can do and now you</p>



<p>kind of understand the idea of linking is taking all the modules stuffing them inside of the final</p>



<p>executable and also putting data inside of the final executable you know like if you&#8217;re creating</p>



<p>So, you know, like if you&#8217;re creating a string variable in your globals area of your assembly</p>



<p>program or hard coding, any kind of string anywhere in your C++, then it&#8217;s got to be</p>



<p>inside of the executable.</p>



<p>Otherwise, it wouldn&#8217;t be anywhere when we ran the program.</p>



<p>So, yeah, it sticks the data in there.</p>



<p>It sticks the segments in there.</p>



<p>It, you know, calculates the jumps and all that stuff.</p>



<p>I just want to point out you could put strings in a configuration file.</p>



<p>of a vanilla C++ or assembly program you probably are making strings directly in the program.</p>



<p>Anyway, so I think that&#8217;s the gist of everything that I really wanted to say about what is the</p>



<p>general idea of the linker. Thanks for watching this video I hope you learned a little bit and</p>



<p>had some fun. I will see you in the next video. Hey everybody thanks for watching this video again</p>



<p>it i do hope you did learn something and have some fun if you could do me a please a small little</p>



<p>favor could you please subscribe and follow this channel or these videos or whatever it is you do</p>



<p>on the current social media website that you&#8217;re looking at right now it would really mean the</p>



<p>world to me and it&#8217;ll help make more videos and grow this community so we&#8217;ll be able to do more</p>



<p>videos longer videos better videos or just i&#8217;ll be able to keep making videos in general so please</p>



<p>and subscribe. You know, sometimes I&#8217;m sleeping in the middle of the night and I just wake up</p>



<p>because I know somebody subscribed or followed. It just wakes me up and I get filled with joy.</p>



<p>That&#8217;s exactly what happens every single time. So you could do it as a nice favor to me or you</p>



<p>could troll me if you want to just wake me up in the middle of the night, just subscribe</p>



<p>and then I&#8217;ll just wake up. I promise that&#8217;s what will happen. Also, if you look at the middle of</p>



<p>the screen right now, you should see a QR code, which you can scan in order to go to the website,</p>



<p>is also named somewhere at the bottom of this video and it&#8217;ll take you to my main website where</p>



<p>you can just kind of like see all the videos I published and the services and tutorials and</p>



<p>things that I offer and all that good stuff and uh if you have a suggestion for uh uh clarifications</p>



<p>or errata or just future videos that you want to see please leave a comment or if you just want to</p>



<p>say hey what&#8217;s up what&#8217;s going on you know just send me a comment whatever I also wake up for</p>



<p>I wake up in a cold sweat and I&#8217;m like, it would really mean the world to me.</p>



<p>I would really appreciate it.</p>



<p>So again, thank you so much for watching this video and enjoy the cool music as I fade into</p>



<p>the darkness, which is coming for us all.</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/how-linkers-work-linking-code-virtual-memory-and-module-jumps-explained/">How Linkers Work: Linking Code, Virtual Memory, and Module Jumps Explained</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/how-linkers-work-linking-code-virtual-memory-and-module-jumps-explained/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Binary to Hex Conversion Made EASY! No Math Needed!</title>
		<link>https://www.NeuralLantern.com/binary-to-hex-conversion-made-easy-no-math-needed/</link>
					<comments>https://www.NeuralLantern.com/binary-to-hex-conversion-made-easy-no-math-needed/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Fri, 02 May 2025 09:21:04 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Conversions]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[binary]]></category>
		<category><![CDATA[binary conversion]]></category>
		<category><![CDATA[binary numbers]]></category>
		<category><![CDATA[binary to hex conversion]]></category>
		<category><![CDATA[coding tutorials]]></category>
		<category><![CDATA[computer basics]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[hex conversion]]></category>
		<category><![CDATA[hexadecimal]]></category>
		<category><![CDATA[hexadecimal numbers]]></category>
		<category><![CDATA[learn programming]]></category>
		<category><![CDATA[number systems]]></category>
		<category><![CDATA[programming for beginners]]></category>
		<category><![CDATA[tech tutorials]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=93</guid>

					<description><![CDATA[<p>Learn binary to hex conversion without math! Simple patterns for computer science students. Watch now for easy tips! #Binary #Hex</p>
<p>The post <a href="https://www.NeuralLantern.com/binary-to-hex-conversion-made-easy-no-math-needed/">Binary to Hex Conversion Made EASY! No Math Needed!</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Binary to Hex Conversion Made EASY! No Math Needed!" width="1380" height="776" src="https://www.youtube.com/embed/9hrPr95c8JA?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Hey there! Struggling with binary to hex conversions? This video makes it SUPER easy—no math required! Learn to convert between binary and hexadecimal with simple patterns you’ll memorize in no time. Perfect for computer science students, coders, or anyone curious about how computers work. Subscribe for more tutorials, and scan the QR code to visit my site for extra resources. Drop a comment with your questions or video ideas! #Binary #Hex #ComputerScience #Coding</p>



<p>Introduction to Binary and Hex Conversion 00:00:00<br>Why Convert Between Binary and Hex 00:00:13<br>Recap of Number Systems 00:00:41<br>Binary Base Two System 00:01:01<br>Hexadecimal Base Sixteen System 00:01:24<br>Benefits of Hexadecimal 00:02:06<br>Simplifying Binary-Hex Conversion 00:03:04<br>Four Bits Equal One Hex Digit 00:04:32<br>Memorizing Binary-Hex Patterns 00:05:13<br>Creating a Binary-Hex Conversion Table 00:06:26<br>Converting Hex to Binary Example 00:08:52<br>Understanding Nibbles and Bytes 00:10:44<br>Converting Binary to Hex Example 00:13:19<br>Conclusion and Verification 00:15:38<br>Call to Subscribe and Engage 00:16:20</p>



<p>Thanks for watching!</p>



<p>Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p>Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p>Hi there! Let&#8217;s talk about converting back and forth between binary and hexadecimal.</p>



<p>Why would you want to do that? Well, maybe you&#8217;re in computer science. Maybe you&#8217;ve been presented</p>



<p>with some numbers that you need to convert. Maybe you have like a bunch of ones and zeros.</p>



<p>Maybe you have like an ox and then something that looks really weird. It&#8217;s got some letters in it,</p>



<p>but it&#8217;s also got some numbers. And you&#8217;re trying to figure out what are these? What are we trying</p>



<p>we try to convert back and forth between.</p>



<p>You should have watched my other videos by now,</p>



<p>which will teach you how to convert back and forth</p>



<p>between both of these number bases and decimal.</p>



<p>So you can understand what they are</p>



<p>in just normal human terms.</p>



<p>But as a quick recap, decimal is a base 10 number system</p>



<p>because we have 10 possible characters that we can use.</p>



<p>We can say zero, one, two, three, four,</p>



<p>five, six, seven, eight, nine.</p>



<p>So that&#8217;s 10 total characters, zero through nine.</p>



<p>We also have binary, which is what computers use, which is a base two system.</p>



<p>It&#8217;s base two because the only characters you have available are just zero and one.</p>



<p>So base two, two characters.</p>



<p>You can represent a number between zero and one in a single digit.</p>



<p>Then we have hexadecimal, which is a way to represent a number in a more compact way.</p>



<p>system there because we have 16 possible characters we have 0 1 2 3 4 5 6 7 8 9</p>



<p>just like decimal but then we add more numbers we had like six numbers we say</p>



<p>a b c d e f and what happens is the a has a strength of 10 whereas the you know</p>



<p>the 9 just to its left had a strength of 9 the a has a strength of 10 the b has a</p>



<p>of 11 the c has a strength of 12 and the d has a strength of 13 and the e has a strength of 14</p>



<p>and the f has a strength of 15 and so you know we just have more characters that we can use in one</p>



<p>single digit which means we can rent we can represent the same number in decimal but just</p>



<p>we can represent it smaller if we use hexadecimal so it&#8217;s kind of useful when you&#8217;re working with</p>



<p>looking at bits in binary or hex and not necessarily decimal because binary as</p>



<p>you&#8217;re going to learn in this video gives you kind of a good idea just by</p>



<p>looking at it after you&#8217;ve practiced a little while gives you a good idea of</p>



<p>what hex numbers you would be seeing if you were looking at the same number and</p>



<p>vice versa if you&#8217;re looking at hex numbers if you look at them a lot in</p>



<p>your daily life you&#8217;ll start to kind of like see through the matrix and you&#8217;ll</p>



<p>And if you&#8217;re interested in finding what bits are on and off,</p>



<p>it&#8217;s convenient to be able to look at a hexadecimal number</p>



<p>and kind of intuitively know,</p>



<p>okay, those bits are probably like on and off.</p>



<p>Those bits are all on, you know, whatever.</p>



<p>So this is the basics of number basis.</p>



<p>Here&#8217;s a trick.</p>



<p>In all my other videos,</p>



<p>when we converted back and forth</p>



<p>between decimal and binary and hex and all that stuff,</p>



<p>we used multiplication, we used division,</p>



<p>you know, we messed with the numbers quite a bit.</p>



<p>the great thing about binary and hex conversions is you don&#8217;t even really need to do math.</p>



<p>Maybe a little math at first while you&#8217;re learning, but eventually when you get used to it,</p>



<p>you start to realize you can memorize short patterns. Let me bring your attention to the</p>



<p>fact that in hexadecimal, you have 16 possible combinations, or you can represent a number</p>



<p>you can do the same thing in four characters if I had four characters right</p>



<p>here in binary very quickly you could do the calculation in your head if you&#8217;ve</p>



<p>watched my other videos you can see well that one counts for a one and this one</p>



<p>counts for a two and this one counts for a four and this one counts for an eight</p>



<p>if I want to know what the maximum value is that I could represent with four</p>



<p>digits I just take the the top numbers strength multiply it by two and then</p>



<p>strength multiply it by 2 and then subtract 1. So if we have 1, 2, 4, 8, I&#8217;ll just multiply 8 by 2,</p>



<p>that&#8217;s 16, and then subtract 1, that&#8217;s 15. So I can represent a number between 0 and 15 with 4</p>



<p>binary digits. But I just said you could do that with one hexadecimal digit, right?</p>



<p>So that means one hexadecimal digit is actually four binary digits. And if you just memorize</p>



<p>16 combinations of numbers, which is not like that hard.</p>



<p>And even if you don&#8217;t memorize them all,</p>



<p>I don&#8217;t have them all memorized.</p>



<p>It&#8217;s really easy to convert in your head</p>



<p>a four digit binary number to decimal</p>



<p>and then convert that back to hexadecimal pretty fast,</p>



<p>hexadecimal.</p>



<p>So what&#8217;s the equivalent of 1111?</p>



<p>Well, we know it&#8217;s the highest possible value</p>



<p>with just one hexadecimal digit.</p>



<p>So that would have to be an F.</p>



<p>So you can memorize already</p>



<p>You can memorize already a couple of really, really easy combinations.</p>



<p>We could say, let me say zero binary, OB to say that we&#8217;re looking at binary is equal</p>



<p>to zero X F. So just the letter F in hex.</p>



<p>Remember that we like to prefix different base number systems to give the reader a reminder</p>



<p>of what base they&#8217;re looking at.</p>



<p>one i&#8217;m going to say that 000 in binary is just zero in hex if i didn&#8217;t put that prefix how would</p>



<p>you know if you&#8217;re looking at hex or binary or decimal it would be even more confusing if you</p>



<p>had like you know one two zero is that hex one two zero or is that uh decimal one two zero i guess it</p>



<p>can&#8217;t be binary one two zero but if we did one one zero now it could be binary or hex or decimal so</p>



<p>i&#8217;m just going to put uh zero b for binary and i&#8217;m going to say it&#8217;s zero so that&#8217;s two of the</p>



<p>of the 16 total possible combinations that we would memorize.</p>



<p>So let&#8217;s iterate through all the combinations.</p>



<p>Just for the sake of making this table more compact,</p>



<p>actually, let me start a new little notepad page here.</p>



<p>I&#8217;m going to omit those prefixes because those are a good idea,</p>



<p>but while we&#8217;re doing our lookups, they&#8217;re a little irritating.</p>



<p>So I&#8217;m going to take them out.</p>



<p>So I&#8217;m going to say 0001.</p>



<p>Let me say this.</p>



<p>So I&#8217;m just going to count from 0 to 15 in binary.</p>



<p>to 15 in binary.</p>



<p>So this is going to be one, one,</p>



<p>and then zero and then zero, one, zero, one, zero, one,</p>



<p>I don&#8217;t know, that&#8217;s a lot of copy pasting.</p>



<p>Let me just double check here that I&#8217;m doing this right.</p>



<p>I should have 16 lines.</p>



<p>I don&#8217;t, so I&#8217;ve done something wrong.</p>



<p>Let&#8217;s see.</p>



<p>So this is like 0, 1, 2, 3, and this is 4.</p>



<p>This is 5, and then 6, and then 7, and this is 8.</p>



<p>Oh, I have that twice.</p>



<p>Okay, 8.</p>



<p>And then since I copy pasted the bottom part,</p>



<p>I think I can probably assume that&#8217;s okay.</p>



<p>One, two, three, four, five, six, seven.</p>



<p>That was kind of spooky.</p>



<p>I guess a lesson learned is that relying on a battery pack</p>



<p>or a light that&#8217;s gonna stay on for many hours</p>



<p>is probably a dumb idea.</p>



<p>Anyway, continuing, we have this table here.</p>



<p>We have like 16 possible combinations.</p>



<p>So now I&#8217;m gonna map these to hexadecimal digits.</p>



<p>uh you know like 10 are going to be really easy right it&#8217;s just going to be zero and then one</p>



<p>and then two you can make a vertical table if you want for yourself I&#8217;m just doing it this way</p>



<p>because it&#8217;s easier the way that I&#8217;m typing in this notepad the way that I&#8217;m typing in this</p>



<p>notepad so I&#8217;m going to do seven eight nine and then when we get to 10 let me just double check</p>



<ol start="10" class="wp-block-list">
<li>So this is eight plus two. So that means this is indeed a 10 and oh, 10 in hex, not a decimal.</li>
</ol>



<p>So that&#8217;s a and then B and then C and then D and then E and then F. Okay. So now that we have this</p>



<p>little table set up, you know, if you want to write it horizontally, that&#8217;s fine. It&#8217;s actually</p>



<p>binary and hex now imagine we have a gigantic hex number zero x and then i&#8217;m just going to do like a</p>



<p>bunch of numbers and then i&#8217;m going to do change some of these to like letters just to make things</p>



<p>more interesting a b c d e did i use any d e f e b i didn&#8217;t use a b oh there we go and i&#8217;ll put like</p>



<p>another aid in there okay so this is huge and this would take like a while to calculate right</p>



<p>to calculate right if you were going to convert it to decimal for hex to binary conversion it&#8217;s</p>



<p>actually pretty easy you literally just go b what is b b is that so b is just that you don&#8217;t even</p>



<p>have to do any math let me copy paste this down here so i can show you a really easy way to do</p>



<p>D is this right here.</p>



<p>So I&#8217;m going to say the D is that.</p>



<p>And then the 6 is that pattern right there.</p>



<p>So move you over.</p>



<p>1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4.</p>



<p>Maybe that&#8217;ll line up later, hopefully.</p>



<p>So the 1 is pretty easy.</p>



<p>Probably didn&#8217;t even need to copy-paste that.</p>



<p>I could have just looked at it and typed.</p>



<p>looked at it and typed the E is going to be that and the seven is going to be that</p>



<p>and the two is going to be this eight see what I&#8217;m doing I&#8217;m literally just</p>



<p>copy pasting the bit patterns if you don&#8217;t have copy paste when you&#8217;re doing your conversion</p>



<p>that&#8217;s okay you can at least write down zeros and ones really fast if it&#8217;s just</p>



<p>you know four at a time I should also point out that um you know this is pretty important to</p>



<p>good term that people like to use. Four bytes or one hexadecimal digit, it&#8217;s called a nibble.</p>



<p>So usually you&#8217;re used to seeing eight bytes in a row and you call that, sorry,</p>



<p>usually you&#8217;re used to seeing eight bits in a row and you call that a byte or two hex digits in a</p>



<p>row and you call that a byte. If you just see four bits or one hex digit, that&#8217;s a nibble.</p>



<p>Two nibbles make a byte. Try to remember that. So we have this giant thing here.</p>



<p>we have literally now successfully converted binary.</p>



<p>I&#8217;m going to put, I&#8217;m just going to put OB here</p>



<p>and then remove all the spaces.</p>



<p>This is the binary number that we originally had</p>



<p>in hexadecimal.</p>



<p>So again, just to emphasize, these are the two same numbers.</p>



<p>They&#8217;re just represented differently.</p>



<p>Differently.</p>



<p>Let me punch this into my personal calculator</p>



<p>to make sure that I gave you the right walkthrough</p>



<p>so I don&#8217;t have to correct in a video later.</p>



<p>so expression X result binary oh god I can&#8217;t even I can&#8217;t even read that okay</p>



<p>so let me let me do it backwards I&#8217;m gonna copy paste this one in there okay</p>



<p>so let&#8217;s see X okay so it&#8217;s telling me that supposed to get to B and then a D6</p>



<p>728fac. Okay, so I did it. And this is also a good reminder that you kind of want to pair off</p>



<p>into groups of one byte at least. So, you know, each two characters, that&#8217;s one byte. One character</p>



<p>by itself is a nibble. So you want to pair off into bytes. And notice how this b is all by itself.</p>



<p>So you want to pad to the left with a zero so that you&#8217;re just kind of working with bytes.</p>



<p>It&#8217;s easier on the eyes and the brain. And you&#8217;ll usually see something like this</p>



<p>output from a program or something. In fact, you might see something like this representing,</p>



<p>here&#8217;s a word, or you might see something like this showing that this is like a D word or,</p>



<p>you know, like a 32 bit number. And if we wanted to say, oh, this is a 64 bit system. So let&#8217;s</p>



<p>look at 64 bits. Let&#8217;s look at eight bytes. Then we&#8217;ll just like pad it with, let&#8217;s see, one, two,</p>



<p>that&#8217;s one, two, three, we&#8217;ll pad it with a bunch more zeros. One, two, three, four, five, six,</p>



<p>So this is a proper 64-bit number or an 8-byte number that works with modern systems,</p>



<p>whether you have the space in there or not.</p>



<p>And so I&#8217;m not going to do another example from hex to binary.</p>



<p>Let&#8217;s do a quick example from binary to hex.</p>



<p>It should be just as easy.</p>



<p>So I&#8217;m going to start a new tab here and just copy-paste the table that I made.</p>



<p>Let&#8217;s make a bunch of random numbers for binary.</p>



<p>And so now we&#8217;ve got like a bunch of numbers.</p>



<p>All we have to do is I&#8217;m going to copy paste this so I don&#8217;t ruin the original thing that</p>



<p>I wrote down.</p>



<p>And I&#8217;m just going to break it up into groups of four, starting from the least powerful</p>



<p>digits, you know, like all the way on the right.</p>



<p>So I&#8217;m going to go doop, doop.</p>



<p>Okay.</p>



<p>So after breaking it into groups of four, you can see that the, you know, the most powerful</p>



<p>digit there is a one all by its lonesome.</p>



<p>I could put 000 to make sure that they&#8217;re all groups of four bits. I don&#8217;t really have to because</p>



<p>I could still kind of understand just by looking at the one that it&#8217;s going to end up being a one</p>



<p>and then literally just translate it the same way I did before. Okay that&#8217;s a 1.</p>



<p>1 0 1 0 that&#8217;s an A. What&#8217;s a thousand and one? It is a nine. What&#8217;s a 0 100?</p>



<p>what&#8217;s one oh one oh a what&#8217;s a thousand and one didn&#8217;t i just do that that&#8217;s a nine</p>



<p>what&#8217;s a zero zero oh ten that&#8217;s going to be a two for sure yeah two i finally got one off the</p>



<p>top of my head one zero one one that&#8217;s a b and then uh basically 15 minus eight i don&#8217;t really</p>



<p>want to work that out of my head right now so i&#8217;m gonna look at the table seven okay i guess i</p>



<p>should have done that easy right like how fast was that so i&#8217;m just going to copy paste these</p>



<p>put an ox in front of it and maybe bunch them into groups of two first to see what&#8217;s up</p>



<p>okay so they&#8217;re not in groups of two that means this one is kind of i should have started grouping</p>



<p>them on the right side kind of messed it up someone just you know rearrange the grouping</p>



<p>Let me punch this into my personal calculator to make sure that I got this right. Actually, let me do this original number here</p>



<p>I must say</p>



<p>This binary number is supposed to be</p>



<p>1 a 9 4 a 9 2 b 7. Okay, we did it</p>



<p>Really easy, right? So every time you have to convert back and forth between binary and hex</p>



<p>It&#8217;s your lucky day because that&#8217;s like one of the easiest conversions you could do</p>



<p>Thanks for watching this video. I hope you learned a little bit of stuff and had some fun</p>



<p>I&#8217;ll see you in the next video.</p>



<p>So we&#8217;ll be able to do more videos longer videos better videos or just I&#8217;ll be able to keep making videos in general</p>



<p>So please do do me a kindness and and subscribe</p>



<p>You know sometimes I&#8217;m sleeping in the middle of the night</p>



<p>And I just wake up because I know somebody subscribed or followed it just wakes me up and I get filled with joy</p>



<p>That&#8217;s exactly what happens every single time</p>



<p>So you could do it as a nice favor to me or you could you control me if you want to just wake me up in the middle</p>



<p>And I just subscribe and then I&#8217;ll just wake up. I promise that&#8217;s what will happen</p>



<p>that&#8217;s what will happen also uh if you look at the middle of the screen right now you should see a</p>



<p>qr code which you can scan in order to go to the website which i think is also named somewhere at</p>



<p>the bottom of this video and it&#8217;ll take you to my main website where you can just kind of like see</p>



<p>all the videos i published and the services and tutorials and things that i offer and all that</p>



<p>good stuff and uh if you have a suggestion for uh uh clarifications or errata or just future videos</p>



<p>future videos that you want to see please leave a comment or if you just want to say hey what&#8217;s up</p>



<p>what&#8217;s going on you know just send me a comment whatever i also wake up for those in the middle</p>



<p>of the night i get i wake up in a cold sweat and i&#8217;m like it would really it really mean the world</p>



<p>to me i would really appreciate it so again thank you so much for watching this video and um enjoy</p>



<p>the cool music as as i fade into the darkness which is coming for us all</p>



<p>Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/binary-to-hex-conversion-made-easy-no-math-needed/">Binary to Hex Conversion Made EASY! No Math Needed!</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/binary-to-hex-conversion-made-easy-no-math-needed/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
