typestar

equ and times in Assembly

Assemble-time constants and repetition.

; equ names assemble-time values; times repeats a definition.
        global _start

        section .data
WIDTH:  equ 8
ROWS:   equ 3
board:  times WIDTH * ROWS db 0 ; 24 zeroed cells
ruler:  db "========", 10
RLEN:   equ $ - ruler

        section .text
_start:
        mov rax, 1
        mov rdi, 1
        mov rsi, ruler
        mov rdx, RLEN
        syscall

        mov rdi, WIDTH * ROWS   ; the assembler did this math
        mov rax, 60             ; exit code 24
        syscall

How it works

  1. equ names a value the assembler folds everywhere.
  2. times WIDTH * ROWS db 0 repeats a definition 24 times.
  3. The exit code 24 was computed before the program ran.

Keywords and builtins used here

The run, in numbers

Lines
21
Characters to type
400
Tokens
62
Three-star pace
55 tpm

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

Type this snippet

Step 3 of 4 in Data, step 9 of 31 in Language basics.

← Previous Next →