<p>I would argue the best way to do this is have some demonstrations prepared: things they can build with the tools you're teaching that "look" flashy and exciting. Show some cool programs written in C, demonstrate some sort of Arduino-based program that looks interesting (a relatively simple one I've seen waters plants), something in assembly that looks interesting, and so forth.</p>

<p>Make them say, "I want to build that!" before you give them the tools to build it or things like it.</p>

CC BY-SA 4.0
2019-11-16T23:17:02.100Z
Could you provide links to such Arduino videos, preferably ones that have source-code attached?
JohnnyApplesauce
CC BY-SA 4.0
2019-11-17T00:45:00.727Z
@JohnnyApplesauce [here's](https://makezine.com/2016/08/31/dog-simple-arduino-controlled-plant-watering/) Make's description of how such a project could work, with a link to the source code and an instructable. No video, but pictures. I'd suggest googling 'cool arduino projects' or 'cool [technology] projects' and it'll give you stuff you're looking for.
auden
CC BY-SA 4.0
2019-11-16T16:42:08.963Z
2019-11-16T16:42:08.963Z
auden
<p>First, just a disambiguation: are you teaching Assembly language or C? Cos, they are not same as your question seems to suggest. C is a high-level procedural clean code language with tremendous abilities to speak to the bare metal similar to but not as Assembler pls. It may help you bridge to assembly but it is not assembly. Let that be clear to your students.</p>

<p>Never taught machine programming/ASM. But your question touches something in me: the need to wow! the student; I have same predilection with students. So I felt obliged &amp; did some talking with friends in the know and some research. </p>

<p>Here’s the widow’s mite I pieced together. Hope it helps:
You can add the following to your first lab “sales pitch’:</p>

<ol>
<li><p>Let the first lab be a NO CODE, no Technical stuff class. Just getting familiar with selves and ASM in a general way with nothing too technical and thus “intimidating” or “off-putting”. The class should be (pardon my cliché): sugar and spice and all things nice. Toward this:</p></li>
<li><p>Add to your spiel, a history of Assembly telling them of Kathleen Booth &amp; others etc. Make it interesting. Search &amp; find some spectacular successes and exploits using ASM and also some disasters of sloppy ASM. Apart from sparking interest and discussion, the last part will have the additional pedagogic value of sensitising the students to their power as oracles speaking to the small dumb “god” in the machine. Also it will put them on notice of the enormous responsibilities their heightened power as bare metal oracles imposes on them to avoid sloppy code (not only for ASM but programming generally).</p></li>
<li><p>Let the students see how the higher level languages with their swagger and leaky algorithms are actually, mostly dependent on ASM and C. Let them see that a lot of our higher level constructs e.g. macro were borrowed from Assembler.</p></li>
<li><p>As @Buffy I. rightly pointed out, talk alone can’t win a non-committal or skeptical mind. To give them something interesting: show them some good things (e.g. games) made in Assembler and display for them on slide (s) the assembly code snippets that made such things. In this regard I found some of these online and hope they may help or stimulate some interesting ideas:
<a href="https://spectrum.ieee.org/geek-life/reviews/three-computer-games-that-make-assembly-language-fun.amp.html" rel="noreferrer">https://spectrum.ieee.org/geek-life/reviews/three-computer-games-that-make-assembly-language-fun.amp.html</a></p></li>
</ol>

<p><a href="https://www.quora.com/What-are-some-cool-assembly-language-projects-I-can-do?top_ans=21546329" rel="noreferrer">https://www.quora.com/What-are-some-cool-assembly-language-projects-I-can-do?top_ans=21546329</a></p>

<p><a href="https://brianslam.wordpress.com/2014/04/06/assembly-is-fun-sort-of/" rel="noreferrer">https://brianslam.wordpress.com/2014/04/06/assembly-is-fun-sort-of/</a></p>

<p><a href="https://news.ycombinator.com/item?id=16710543" rel="noreferrer">https://news.ycombinator.com/item?id=16710543</a></p>

<p>This one is a Compendium of Assembly Coding Practices from Coding Project. It may help illuminate your teaching:
<a href="https://www.codeproject.com/Articles/1116188/40-Basic-Practices-in-Assembly-Language-Programmin" rel="noreferrer">https://www.codeproject.com/Articles/1116188/40-Basic-Practices-in-Assembly-Language-Programmin</a></p>

CC BY-SA 4.0
2019-11-07T12:07:48.313Z
2019-11-07T13:25:15.990Z
2019-11-07T13:25:15.990Z
Mallam Awal
<p>You may not win if you just use words. Instead, give them interesting but challenging exercises to do. </p>

<p>One of the most fun exercises I ever did was to produce a <a href="https://en.wikipedia.org/wiki/Quine_%28computing%29" rel="nofollow noreferrer">Quine</a> in assembly language. But, instead of producing a textual version of itself, as most Quines do, it produces a running copy in memory and then executes (branches to) that copy. The copy seems to act as if the program is moving through memory. As such, the program is called an Animal. This was once a standard exercise at Dartmouth, and I learned it from faculty and students there. </p>

<p>A more elaborate version will erase the old copy as it creates the new. </p>

<p>The book XINU (XINU Is Not Unix) by Douglas Comer has some interesting things. One of which is a microkernel for an OS. </p>

<p>Unfortunately, this is also one of the skills needed by machine level hackers. </p>

<p>To run such a program you need to assure that the OS won't get in your way, however, so you might need to do this on a simulator. </p>

<p>You can also do interesting things with race conditions and such that are harder to teach in higher level languages. </p>

CC BY-SA 4.0
2019-11-06T19:34:06.687Z
I appreciate your enthusiasm, but the students won’t even be able to do that by the end of the class, let alone the beginning. I’m pretty sure no one but the well self-studied (whom I don’t need to reach) can even write a Python or Java quine.
JohnnyApplesauce
CC BY-SA 4.0
2019-11-06T19:35:42.137Z
Actually a machine language Quine is a lot easier than one in Java. You don't have to carry as much of the structure of a program to get it done. Try it yourself.
Buffy
CC BY-SA 4.0
2019-11-06T17:59:29.547Z
2019-11-06T17:59:29.547Z
Buffy
<p>I may be late to game, but you should target four &quot;wow&quot;s:</p>
<ul>
<li>&quot;wow, how small .exe file is!&quot;</li>
<li>&quot;wow, how fast this program is compared to Python!&quot;</li>
<li>&quot;wow, and THAT is how it's done!&quot;</li>
<li>&quot;wow, I'm a hacker now!&quot;</li>
</ul>
<p>For first one, you should compare compiled sizes of some Go, C++, C and assembler programs which all do a same thing. (Mandelbrot fractal generator in Asm is 61 bytes! Check <a href="https://github.com/leto/asmutils/blob/master/src/bonus/mandelbrot.asm" rel="nofollow noreferrer">https://github.com/leto/asmutils/blob/master/src/bonus/mandelbrot.asm</a>, it is runnable)</p>
<p>For second you should show implementation of some number crunching algorithm (beware GPU computing -- try to find example, which can't be sped up with GPUs or optimized by SIMD)</p>
<p>For third one, I like to explain the MBR (even though it is no longer popular). You can put a small command line in 512 bytes of MBR, and load it as floppy in QEMU or from USB on real hardware. It often looks like miracle that you can run code without OS. (<a href="http://www.osdever.net/tutorials/view/hello-world-boot-loader" rel="nofollow noreferrer">http://www.osdever.net/tutorials/view/hello-world-boot-loader</a>)</p>
<p>For fourth one, show how to disassemble code in a disassembler, edit some string, save and run it with new string. Patching binaries no longer will look like mystery.</p>

CC BY-SA 4.0
2020-10-28T02:32:51.420Z
Swell answer! Can you expand on last para? Which disassembler? Also the 61 byte asm... Which assembler is it? Nasm?
Rushi
CC BY-SA 4.0
2020-10-28T09:42:09.027Z
@Rusi as for 61 byte -- this is in 16bit mode mode fasm. I have a blogpost about it, but it is in Ukrainian :/ https://danbst.wordpress.com/2010/03/01/os_interpreter/ , full source code in the end. As for disassembler -- IDApro or Ollydbg are the h4ck3r tools.
danbst
CC BY-SA 4.0
2020-10-28T10:35:06.380Z
Looks impressive. And google goes a long way with the Ukrainian
Rushi
CC BY-SA 4.0
2020-10-27T21:56:40.820Z
2020-10-27T21:56:40.820Z
danbst
<p><a href="https://en.wikipedia.org/wiki/Forth_(programming_language)" rel="nofollow noreferrer">Forth</a> is very interesting language which can run on bare metal, and also be as high level as you want (I've see a compiler/interpreter of subset of Pascal implemented in 11 pages)  and will stretch brain of your students. I know it did mine :-)</p>

<p>And is trivial to code some definitions in Assembly if you want.</p>

<p>Code is incredibly compact, ideal (and still used) for embedded systems.</p>

CC BY-SA 4.0
2019-11-12T23:17:47.117Z
I am only a TA. Also, these students will likely freak out knowing that they will be introduced to **three** new things (C, x86-64 asm, and Forth). Your suggestion can help other teachers though!
JohnnyApplesauce
CC BY-SA 4.0
2019-11-13T22:17:13.087Z
@JohnnyApplesauce -  It depends how much you want to stretch you students' brain. C is close enough to other languages to be of little comparable (to Forth) interest. You can ignore ASM, to understand Forth student just to have understand the RAM memory and stack (no ASM commands are necessary). And Forth has interactive commandline interpreter, very easy (and fun) to poke around.
Peter M. - stands for Monica
CC BY-SA 4.0
2019-11-12T23:08:03.463Z
2019-11-12T23:08:03.463Z
Peter M. - stands for Monica
<p>Next semester I will be TAing a computer organization/assembly language course. I will be full-fledgedly (co-)teaching the lab. The first lab will take place before the first lecture, so me and the other TA will partly be responsible for preparing the students to not resent this class they're forced to take. At this point, the students have taken an intro class with Python and a class on OO concepts in Java, and they might be taking a language-agnostic algorithms class at the same time. The professor's standard way of motivating the concept on the first day is showing how going through an array column by column is slower than row by row even though they give the same result using the same approach.</p>

<p>Therefore, I have to motivate on two fronts: why is assembly programming (or even C) interesting/relevant, and why is computer organization interesting/relevant. The latter may seem obvious if you're already in the know, but it sure didn't for me before I took this very course.</p>

<p>Here are some of the points that I already intend to include in my opening spiel (everything that starts with a backslash is spurious):</p>

<p>"If you go into data science: the information in this course will explain why certain programs are slow, which is important if you're churning a lot of data.<br>
\You will learn how to write faster programs in general.<br>
You will understand how computers actually work, no magic [I don't have to mention that they won't learn everything].<br>
\This class might make you interested in systems-level programming, even considering a career.<br>
Do you ever feel awed at those other guys with their cool Arduino or Raspberry Pi projects? This class will teach you how to do what they do."</p>

<p>What are some other motivators that I can include?</p>

<p>EDIT: Just to be clear: I have no control over the lab, and definitely none over the lecture. I won't even be present for the professor's lecture. What I have control over is what I explain as I explain the pre-baked labs, which in the first three weeks include an introduction to ssh, C, certain binary algorithms, and pointers. Aside from the ssh, these are supposed to segue everyone into asm.</p>

CC BY-SA 4.0
2020-04-22T12:00:20.447Z
@JohnnyApplesauce, many processors (CISCy ones, at least) have special addressing modes that multiply a displacement by an assortment of small (basic data sizes, mostly) constants, so "address the next data item" if it is up to 8 bytes long is free. Also, accessing the item next in memory is faster than grabbing one far away (today's machines rely heavily on cache, typical RAM access time is hundreds (!) of instructions worth).
vonbrand
CC BY-SA 4.0
2019-11-08T05:37:44.210Z
"Going through an array column by column is slower than row by row even though they give the same result using the same approach." Seems like that's a result of how you represent the array, rather than an inherent property of arrays.
Acccumulation
CC BY-SA 4.0
2019-11-08T12:33:39.360Z
...ooh, maybe I misunderstood the professor. Isn’t incrementing the pointer by the size of the objects in the array less expensive than multiplying by the length of the array? Wouldn’t going column by column require n*n multiplications rather than n multiplications, making it slower for increasingly large values?
JohnnyApplesauce
CC BY-SA 4.0
2019-11-10T22:27:45.777Z
Presumably, you are discussing an array in which each element is itself an array, and this array represents a two-dimension array. And you're saying that when you iterate, it's faster to match your iteration nesting to the array nesting (outer iteration loop iterates over outer array). So far so good. But then your position seems to be resting on the unstated assumption that the inner arrays represent rows.
Acccumulation
CC BY-SA 4.0
2019-11-10T22:27:51.890Z
My point is that your wording makes it sound like there is some difference between "rows" and "columns", but it is more accurate to word it in terms of inner and outer arrays. That going by rows is faster is an aspect of the *representation*, not anything intrinsic to "rows". As far as the actual data is concerned, there are no rows or columns. That's just an abstraction we place on top of it.
Acccumulation
<student-motivation><assembly><architecture><hardware>
How do you wow second-year students into saying "bare-metal programming is cool!"?
# How do you wow second-year students into saying "bare-metal programming is cool!"?

(Asked by: username_0 on 2019-11-06)

Next semester I will be TAing a computer organization/assembly language course. I will be full-fledgedly (co-)teaching the lab. The first lab will take place before the first lecture, so me and the other TA will partly be responsible for preparing the students to not resent this class they're forced to take. At this point, the students have taken an intro class with Python and a class on OO concepts in Java, and they might be taking a language-agnostic algorithms class at the same time. The professor's standard way of motivating the concept on the first day is showing how going through an array column by column is slower than row by row even though they give the same result using the same approach.

Therefore, I have to motivate on two fronts: why is assembly programming (or even C) interesting/relevant, and why is computer organization interesting/relevant. The latter may seem obvious if you're already in the know, but it sure didn't for me before I took this very course.

Here are some of the points that I already intend to include in my opening spiel (everything that starts with a backslash is spurious):

"If you go into data science: the information in this course will explain why certain programs are slow, which is important if you're churning a lot of data.  
\You will learn how to write faster programs in general.  
You will understand how computers actually work, no magic [I don't have to mention that they won't learn everything].  
\This class might make you interested in systems-level programming, even considering a career.  
Do you ever feel awed at those other guys with their cool Arduino or Raspberry Pi projects? This class will teach you how to do what they do."

What are some other motivators that I can include?

EDIT: Just to be clear: I have no control over the lab, and definitely none over the lecture. I won't even be present for the professor's lecture. What I have control over is what I explain as I explain the pre-baked labs, which in the first three weeks include an introduction to ssh, C, certain binary algorithms, and pointers. Aside from the ssh, these are supposed to segue everyone into asm.

**Tags:** student-motivation, assembly, architecture, hardware

> **Comments:**
> **username_2**: "Going through an array column by column is slower than row by row even though they give the same result using the same approach." Seems like that's a result of how you represent the array, rather than an inherent property of arrays.  
> **username_0**: ...ooh, maybe I misunderstood the professor. Isn’t incrementing the pointer by the size of the objects in the array less expensive than multiplying by the length of the array? Wouldn’t going column by column require n*n multiplications rather than n multiplications, making it slower for increasingly large values?  
> **username_2**: Presumably, you are discussing an array in which each element is itself an array, and this array represents a two-dimension array. And you're saying that when you iterate, it's faster to match your iteration nesting to the array nesting (outer iteration loop iterates over outer array). So far so good. But then your position seems to be resting on the unstated assumption that the inner arrays represent rows.  
> **username_2**: My point is that your wording makes it sound like there is some difference between "rows" and "columns", but it is more accurate to word it in terms of inner and outer arrays. That going by rows is faster is an aspect of the *representation*, not anything intrinsic to "rows". As far as the actual data is concerned, there are no rows or columns. That's just an abstraction we place on top of it.  
> **username_1**: @username_0, many processors (CISCy ones, at least) have special addressing modes that multiply a displacement by an assortment of small (basic data sizes, mostly) constants, so "address the next data item" if it is up to 8 bytes long is free. Also, accessing the item next in memory is faster than grabbing one far away (today's machines rely heavily on cache, typical RAM access time is hundreds (!) of instructions worth).  

---

## 5 answers

### Answer by username_4 on 2019-11-07. Score: 7 | Accepted answer

First, just a disambiguation: are you teaching Assembly language or C? Cos, they are not same as your question seems to suggest. C is a high-level procedural clean code language with tremendous abilities to speak to the bare metal similar to but not as Assembler pls. It may help you bridge to assembly but it is not assembly. Let that be clear to your students.

Never taught machine programming/ASM. But your question touches something in me: the need to wow! the student; I have same predilection with students. So I felt obliged & did some talking with friends in the know and some research.

Here’s the widow’s mite I pieced together. Hope it helps:
You can add the following to your first lab “sales pitch’:

1. Let the first lab be a NO CODE, no Technical stuff class. Just getting familiar with selves and ASM in a general way with nothing too technical and thus “intimidating” or “off-putting”. The class should be (pardon my cliché): sugar and spice and all things nice. Toward this:
2. Add to your spiel, a history of Assembly telling them of Kathleen Booth & others etc. Make it interesting. Search & find some spectacular successes and exploits using ASM and also some disasters of sloppy ASM. Apart from sparking interest and discussion, the last part will have the additional pedagogic value of sensitising the students to their power as oracles speaking to the small dumb “god” in the machine. Also it will put them on notice of the enormous responsibilities their heightened power as bare metal oracles imposes on them to avoid sloppy code (not only for ASM but programming generally).
3. Let the students see how the higher level languages with their swagger and leaky algorithms are actually, mostly dependent on ASM and C. Let them see that a lot of our higher level constructs e.g. macro were borrowed from Assembler.
4. As @username_5 I. rightly pointed out, talk alone can’t win a non-committal or skeptical mind. To give them something interesting: show them some good things (e.g. games) made in Assembler and display for them on slide (s) the assembly code snippets that made such things. In this regard I found some of these online and hope they may help or stimulate some interesting ideas:
   <https://spectrum.ieee.org/geek-life/reviews/three-computer-games-that-make-assembly-language-fun.amp.html>

<https://www.quora.com/What-are-some-cool-assembly-language-projects-I-can-do?top_ans=21546329>

<https://brianslam.wordpress.com/2014/04/06/assembly-is-fun-sort-of/>

<https://news.ycombinator.com/item?id=16710543>

This one is a Compendium of Assembly Coding Practices from Coding Project. It may help illuminate your teaching:
<https://www.codeproject.com/Articles/1116188/40-Basic-Practices-in-Assembly-Language-Programmin>


---

### Answer by username_5 on 2019-11-06. Score: 4

You may not win if you just use words. Instead, give them interesting but challenging exercises to do.

One of the most fun exercises I ever did was to produce a [Quine](https://en.wikipedia.org/wiki/Quine_%28computing%29) in assembly language. But, instead of producing a textual version of itself, as most Quines do, it produces a running copy in memory and then executes (branches to) that copy. The copy seems to act as if the program is moving through memory. As such, the program is called an Animal. This was once a standard exercise at Dartmouth, and I learned it from faculty and students there.

A more elaborate version will erase the old copy as it creates the new.

The book XINU (XINU Is Not Unix) by Douglas Comer has some interesting things. One of which is a microkernel for an OS.

Unfortunately, this is also one of the skills needed by machine level hackers.

To run such a program you need to assure that the OS won't get in your way, however, so you might need to do this on a simulator.

You can also do interesting things with race conditions and such that are harder to teach in higher level languages.

> **Comments:**
> **username_0**: I appreciate your enthusiasm, but the students won’t even be able to do that by the end of the class, let alone the beginning. I’m pretty sure no one but the well self-studied (whom I don’t need to reach) can even write a Python or Java quine.  
> **username_5**: Actually a machine language Quine is a lot easier than one in Java. You don't have to carry as much of the structure of a program to get it done. Try it yourself.  

---

### Answer by username_6 on 2020-10-27. Score: 2

I may be late to game, but you should target four "wow"s:

* "wow, how small .exe file is!"
* "wow, how fast this program is compared to Python!"
* "wow, and THAT is how it's done!"
* "wow, I'm a hacker now!"

For first one, you should compare compiled sizes of some Go, C++, C and assembler programs which all do a same thing. (Mandelbrot fractal generator in Asm is 61 bytes! Check <https://github.com/leto/asmutils/blob/master/src/bonus/mandelbrot.asm>, it is runnable)

For second you should show implementation of some number crunching algorithm (beware GPU computing -- try to find example, which can't be sped up with GPUs or optimized by SIMD)

For third one, I like to explain the MBR (even though it is no longer popular). You can put a small command line in 512 bytes of MBR, and load it as floppy in QEMU or from USB on real hardware. It often looks like miracle that you can run code without OS. (<http://www.osdever.net/tutorials/view/hello-world-boot-loader>)

For fourth one, show how to disassemble code in a disassembler, edit some string, save and run it with new string. Patching binaries no longer will look like mystery.

> **Comments:**
> **username_7**: Swell answer! Can you expand on last para? Which disassembler? Also the 61 byte asm... Which assembler is it? Nasm?  
> **username_6**: @Rusi as for 61 byte -- this is in 16bit mode mode fasm. I have a blogpost about it, but it is in Ukrainian :/ https://username_6.wordpress.com/2010/03/01/os_interpreter/ , full source code in the end. As for disassembler -- IDApro or Ollydbg are the h4ck3r tools.  
> **username_7**: Looks impressive. And google goes a long way with the Ukrainian  

---

### Answer by username_8 on 2019-11-12. Score: 2

[Forth](https://en.wikipedia.org/wiki/Forth_(programming_language)) is very interesting language which can run on bare metal, and also be as high level as you want (I've see a compiler/interpreter of subset of Pascal implemented in 11 pages) and will stretch brain of your students. I know it did mine :-)

And is trivial to code some definitions in Assembly if you want.

Code is incredibly compact, ideal (and still used) for embedded systems.

> **Comments:**
> **username_0**: I am only a TA. Also, these students will likely freak out knowing that they will be introduced to **three** new things (C, x86-64 asm, and Forth). Your suggestion can help other teachers though!  
> **username_8**: @username_0 -  It depends how much you want to stretch you students' brain. C is close enough to other languages to be of little comparable (to Forth) interest. You can ignore ASM, to understand Forth student just to have understand the RAM memory and stack (no ASM commands are necessary). And Forth has interactive commandline interpreter, very easy (and fun) to poke around.  

---

### Answer by username_3 on 2019-11-16. Score: 1

I would argue the best way to do this is have some demonstrations prepared: things they can build with the tools you're teaching that "look" flashy and exciting. Show some cool programs written in C, demonstrate some sort of Arduino-based program that looks interesting (a relatively simple one I've seen waters plants), something in assembly that looks interesting, and so forth.

Make them say, "I want to build that!" before you give them the tools to build it or things like it.

> **Comments:**
> **username_0**: Could you provide links to such Arduino videos, preferably ones that have source-code attached?  
> **username_3**: @username_0 [here's](https://makezine.com/2016/08/31/dog-simple-arduino-controlled-plant-watering/) Make's description of how such a project could work, with a link to the source code and an instructable. No video, but pictures. I'd suggest googling 'cool arduino projects' or 'cool [technology] projects' and it'll give you stuff you're looking for.  

---

