typestar

Data sizes in Assembly

db, dw, dq: bytes, words, quadwords, declared and measured.

; db, dw, dd, dq declare initialized bytes through quadwords.
        global _start

        section .data
tag:    db "v2", 10             ; three bytes
small:  dw 300                  ; two bytes
wide:   dq 1000000              ; eight bytes
taglen: equ $ - small - 10      ; equ computes at assemble time

        section .text
_start:
        mov rax, 1
        mov rdi, 1
        mov rsi, tag
        mov rdx, 3
        syscall

        movzx rdi, word [small] ; load 300 -> exit 300 mod 256 = 44
        mov rax, 60
        syscall

How it works

  1. Each directive reserves and initializes its own width.
  2. movzx loads the 16-bit word without sign garbage.
  3. Exit codes are one byte: 300 leaves as 300 mod 256 = 44.

Keywords and builtins used here

The run, in numbers

Lines
20
Characters to type
448
Tokens
60
Three-star pace
55 tpm

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

Type this snippet

Step 1 of 4 in Data, step 7 of 31 in Language basics.

← Previous Next →