typestar

dec y jnz en Assembly

La cuenta regresiva más apretada: decrementa hasta la bandera cero.

; dec + jnz is the tightest countdown: the zero flag ends it.
        global _start

        section .data
tick:   db "tick", 10
TLEN:   equ $ - tick

        section .text
_start:
        mov r12, 3              ; r12 survives syscalls
.again:
        mov rax, 1
        mov rdi, 1
        mov rsi, tick
        mov rdx, TLEN
        syscall

        dec r12
        jnz .again

        mov rax, 60
        xor rdi, rdi
        syscall

Cómo funciona

  1. r12 sobrevive los syscalls — los registros preservados importan.
  2. dec fija la bandera cero; jnz gira sobre ella.
  3. Tres ticks se imprimen, luego una salida limpia.

Palabras clave y builtins usados aquí

El intento, en números

Líneas
23
Caracteres a escribir
324
Tokens
54
Ritmo de tres estrellas
55 tpm

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

Ronda más rápida

  1. seame73310 tpm

Escribe este fragmento

Paso 3 de 4 en Control de flujo; paso 13 de 31 en Fundamentos del lenguaje.

← Anterior Siguiente →