Last active
April 10, 2025 00:24
-
-
Save Joc193/fa09a81226522e491ea03cb89be8235f to your computer and use it in GitHub Desktop.
Programas ARM64 para RaspbianOS
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
/* | |
* --------------------------------------------------------------------------------- | |
* Lenguajes de Interfaz en TECNM Campus ITT | |
* Autor: Jocelyn Alvarez Paniagua | |
* Fecha: 2025-04-07 | |
* Descripción: 3. Imprimir los enteros pares del 2 al 48 | |
* Demostración: [ https://asciinema.org/a/FA3Tabj2EMtjlzfrLquSW0ijH ] | |
* --------------------------------------------------------------------------------- | |
*/ | |
.global _start | |
.section .data | |
newline: .asciz "\n" | |
buffer: .skip 20 | |
.section .text | |
_start: | |
mov x20, #2 | |
mov x21, #48 | |
loop: | |
cmp x20, x21 | |
bgt end | |
mov x0, x20 | |
bl int_to_ascii | |
mov x0, #1 | |
ldr x1, =buffer | |
mov x2, x22 | |
mov x8, #64 | |
svc #0 | |
mov x0, #1 | |
ldr x1, =newline | |
mov x2, #1 | |
mov x8, #64 | |
svc #0 | |
add x20, x20, #2 | |
b loop | |
end: | |
mov x0, #0 | |
mov x8, #93 | |
svc #0 | |
int_to_ascii: | |
mov x1, x0 | |
ldr x2, =buffer | |
add x2, x2, #19 | |
mov x22, #0 | |
itoa_loop: | |
mov x3, #10 | |
udiv x4, x1, x3 | |
msub x5, x4, x3, x1 | |
add x5, x5, #'0' | |
strb w5, [x2] | |
sub x2, x2, #1 | |
add x22, x22, #1 | |
mov x1, x4 | |
cmp x1, #0 | |
bne itoa_loop | |
add x2, x2, #1 | |
copy_ascii: | |
mov x3, #0 | |
ldr x5, =buffer | |
copy_loop: | |
ldrb w4, [x2, x3] | |
strb w4, [x5, x3] | |
add x3, x3, #1 | |
cmp x3, x22 | |
blt copy_loop | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment