Home

Web Assembly Basics

Resources

  1. Web Assembly docs
  2. Learn hexidecimal
  3. Gem's website

Binary Overview

This section simply talks over the simplicity of 1s and 0s being the powerhouses behind the technologies that we use today.

This overview speaks to binary, what bytes are and how the counting works in the base two system.

Represent the number 7 in binary

Endianness

When computes intepret instructions, they need to know the byte order known as endianness. Little endian is right-to-left, but we might also read in ascending order (big endian).

The formatting can depend on the computer architecture.

Most modern computers use little endian.

Which is little endian for 1?

Select one answer

Web Assembly docs

A link to the docs for memory instructions can be found here. That being said, it is mentioned that you will not often go here.

This is more important if you are a micro-architecture engineer.

Hexadecimal

The phrase machine code is often used when describing low-level programming. Hex is the lowest form of "human-readable" format that we can program in.

The example given is 0x2E7 which can be calculated like so:

Math block

743=(2562)+(1614)+(17)743 = (256 * 2) + (16 * 14) + (1 * 7)

A great website for understanding Hexadecimal.

What does 0x1F2 represent

Convert Hex & Binary to string

We can use our toString() method.

Object.prototype.toString(radix)

Radix refers to the base.

Radix/BaseType
2binary
10decimal
16hexidecimal

function hexToDecimal(hex) { return hex.toString(16) } // hexToDecimal(0x2e7) function decimalToBinary(decimal) { return decimal.toString(2) } // decimalToBinary(22)

Memory

The ability to store these 1s and 0s in state. There is long-term and short-term memory.

I skipped over notes for this section as it was more of a repeat from uni.

Numeric Types

This is a review on different forms.

TypeExample
Floating Point142.24
Integer123
Unsigned Int123 (gives back signed bit for space

Under the hood, all numbers in javaascript are 64-bit floating points whereas Web Assembly are all memory pointers of 32-bit.

Repository

https://github.com/okeeffed/developer-notes-nextjs/content/web-assembly/1-web-assembly-basics

Sections


Related