Last active
February 29, 2024 23:41
-
-
Save LaChivaloca69/f96543704eb97e0cc145a81c0843fbad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Instituto Tecnologico de Tijuana | |
| @Depto de Sistemas y Computacion | |
| @Ing. En Sistemas Computacionales | |
| @Autores: Alvarado Cardona Antonio @nickname Lachivaloca | |
| @Autores: Cuevas Estrada Joel @nickname Sh0cko | |
| @Autores: Narvaez Mata Alejandro @nickname AlejandrooNM | |
| ´´´ | |
| section .data | |
| num db 0 ; Variable para almacenar el número | |
| section .text | |
| global _start | |
| _start: | |
| ; Escribe un mensaje para ingresar el número | |
| mov eax, 4 | |
| mov ebx, 1 | |
| mov ecx, mensaje_ingreso | |
| mov edx, mensaje_ingreso_len | |
| int 0x80 | |
| ; Lee el número ingresado | |
| mov eax, 3 | |
| mov ebx, 0 | |
| mov ecx, num | |
| mov edx, 1 | |
| int 0x80 | |
| ; Convierte el carácter a número | |
| sub num, '0' | |
| ; Verifica si el número es par o impar | |
| mov eax, num | |
| test eax, 1 ; Comprueba el bit menos significativo para determinar paridad | |
| jz numero_par ; Salta si es cero (par) | |
| jmp numero_impar ; Salta si es uno (impar) | |
| numero_par: | |
| ; Escribe un mensaje indicando que el número es par | |
| mov eax, 4 | |
| mov ebx, 1 | |
| mov ecx, mensaje_par | |
| mov edx, mensaje_par_len | |
| int 0x80 | |
| jmp fin_programa | |
| numero_impar: | |
| ; Escribe un mensaje indicando que el número es impar | |
| mov eax, 4 | |
| mov ebx, 1 | |
| mov ecx, mensaje_impar | |
| mov edx, mensaje_impar_len | |
| int 0x80 | |
| fin_programa: | |
| ; Termina el programa | |
| mov eax, 1 | |
| xor ebx, ebx | |
| int 0x80 | |
| section .data | |
| mensaje_ingreso db 'Ingresa un número: ', 0 | |
| mensaje_ingreso_len equ $ - mensaje_ingreso | |
| mensaje_par db 'El número es par.', 0 | |
| mensaje_par_len equ $ - mensaje_par | |
| mensaje_impar db 'El número es impar.', 0 | |
| mensaje_impar_len equ $ - mensaje_impar | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
section .text
global _start ; declaración global para el punto de entrada del programa
_start:
; Escribir "Hola Mundo" en la salida estándar (stdout)
section .data
msg db 'Hola Mundo',0xa ; el mensaje que queremos imprimir
len equ $ - msg ; calcula la longitud del mensaje