typestar

Loads and stores in Assembly

byte, word, qword at memory — and movzx to widen cleanly.

; Sizes matter at memory: byte, word, dword, qword -- and movzx.
        global _start

        section .data
flags:  db 0x0F
counts: dw 500

        section .bss
spare:  resb 8                  ; reserved, uninitialized

        section .text
_start:
        movzx rax, byte [flags] ; zero-extend the byte: 15
        movzx rbx, word [counts]
        mov qword [spare], rax  ; store, then load it back
        mov rdi, [spare]
        add rdi, rbx            ; 15 + 500 = 515 -> exit 3 (mod 256)

        mov rax, 60
        syscall

How it works

  1. .bss reserves uninitialized space with resb.
  2. movzx zero-extends narrow loads into full registers.
  3. 515 mod 256 = 3: the one-byte exit truncates.

Keywords and builtins used here

The run, in numbers

Lines
20
Characters to type
445
Tokens
58
Three-star pace
55 tpm

At the three-star pace of 55 tokens a minute, this run takes about 63 seconds.

Type this snippet

Step 2 of 4 in Data, step 8 of 31 in Language basics.

← Previous Next →