section .data
    prompt db "Ingresa un digito (0-9): "
    prompt_len equ $-prompt

    msg_par db "El numero es PAR", 10
    msg_par_len equ $-msg_par

    msg_impar db "El numero es IMPAR", 10
    msg_impar_len equ $-msg_impar

section .bss
    num resb 2

section .text
    global _start

_start:
    ; Mostramos mensaje de solicitud
    mov rax, 1
    mov rdi, 1
    mov rsi, prompt
    mov rdx, prompt_len
    syscall

    ; Leemos el digito
    mov rax, 0
    mov rdi, 0
    mov rsi, num
    mov rdx, 2
    syscall

    ; Convertimos ASCII a numero
    mov al, [num]
    sub al, '0'

verificar:
    cmp al, 0
    je es_par

    cmp al, 1
    je es_impar

    sub al, 2
    jmp verificar

es_par:
    mov rax, 1
    mov rdi, 1
    mov rsi, msg_par
    mov rdx, msg_par_len
    syscall
    jmp salir

es_impar:
    mov rax, 1
    mov rdi, 1
    mov rsi, msg_impar
    mov rdx, msg_impar_len
    syscall

salir:
    mov rax, 60
    mov rdi, 0
    syscall

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: