typestar

Registers and mov in Assembly

Copy between registers; 32-bit writes zero the top half.

; mov copies; registers come in 64, 32, 16, and 8-bit views.
        global _start

        section .text
_start:
        mov rax, 40             ; full 64-bit register
        mov rbx, rax            ; register to register
        mov ecx, 2              ; 32-bit write zeroes the top half
        add rbx, rcx

        mov rdi, rbx            ; exit code 42
        mov rax, 60
        syscall

How it works

  1. mov rbx, rax copies register to register.
  2. Writing ecx clears the upper 32 bits of rcx — for free.
  3. The exit code carries the computed 42 out.

Keywords and builtins used here

The run, in numbers

Lines
13
Characters to type
323
Tokens
35
Three-star pace
60 tpm

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

Type this snippet

Step 3 of 3 in First programs, step 3 of 31 in Language basics.

← Previous Next →