typestar

Bit a bit en Assembly

and, or, xor, shl: aritmética debajo de la aritmética.

; and, or, xor, and the shifts: arithmetic below arithmetic.
        global _start

        section .text
_start:
        mov rax, 0b1100
        mov rbx, 0b1010

        mov rcx, rax
        and rcx, rbx            ; 0b1000 = 8
        mov rdx, rax
        or  rdx, rbx            ; 0b1110 = 14
        xor rax, rbx            ; 0b0110 = 6

        shl rax, 2              ; 24
        add rax, rcx            ; 32
        add rax, rdx            ; 46
        mov rdi, rax
        mov rax, 60             ; exit code 46
        syscall

Cómo funciona

  1. Los literales binarios como 0b1100 dejan los bits a la vista.
  2. and enmascara, or une, xor diferencia.
  3. shl rax, 2 multiplica por cuatro en un corrimiento.

Palabras clave y builtins usados aquí

El intento, en números

Líneas
20
Caracteres a escribir
416
Tokens
64
Ritmo de tres estrellas
55 tpm

Al ritmo de tres estrellas de 55 tokens por minuto, este intento toma unos 70 segundos.

Escribe este fragmento

Paso 1 de 4 en Bits y banderas; paso 15 de 31 en Fundamentos del lenguaje.

← Anterior Siguiente →