Check out a free preview of the full Web Assembly (Wasm) course:
The "Stack & OpCode Exercise" Lesson is part of the full, Web Assembly (Wasm) course featured in this preview video. Here's what you'd learn in this lesson:

Students are instructed to create a "minusone" function that takes a 32-bit integer and subtracts one from it.

Get Unlimited Access Now

Transcript from the "Stack & OpCode Exercise" Lesson

[00:00:00]
>> Let's write some more Web Assembly, for this one without cheating, you can cheat if you want. I mean, I'm not your dad, or your teacher, wait, I am your teacher don't cheat. But if you want it to, or if you need a shortcut, you can click here but create a minus 1 function that takes a 32 bit integer and subtracts 1.

[00:00:19] So all the nodding when I was saying, yeah, we get the stack and all that. Let's see if you really do get it, so I'll give you 5 minutes on that. And the thing to note, remember if we're subtracting 1, we can just use a constant and we can declare i32.const that 1.

[00:00:40] Okay, so again, I really encourage you to write this by hand and not copy paste and skip ahead. It will resonate deeper when you do it yourself.