Last active
April 11, 2025 06:51
-
-
Save Joc193/a550291a5eb37116c35624692438e718 to your computer and use it in GitHub Desktop.
Programa ARM64 - Imprimir el patrón 3x6 y luego invertirlo a 6x3
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-10 | |
* Descripción: Imprimir el patrón 3x6 y luego invertirlo a 6x3 | |
* Demostración: [ https://asciinema.org/a/bArAYLZyMJvcD1ZqM6a4Uk9YB ] | |
* --------------------------------------------------------------------------------- | |
*/ | |
.global _start | |
.section .data | |
mensaje1: .asciz "Patron 3x6:\n" | |
mensaje2: .asciz "\nPatron 6x3:\n" | |
newline: .asciz "\n" | |
espacio: .asciz " " | |
patron: .byte 1,0,0,1,0,1, 1,0,0,0,0,1, 0,1,1,1,0,1 | |
.section .bss | |
buffer: .skip 2 | |
.section .text | |
_start: | |
// Imprimir encabezado | |
mov x0, #1 | |
ldr x1, =mensaje1 | |
mov x2, #14 | |
mov x8, #64 | |
svc #0 | |
// Imprimir patrón 3x6 (3 filas, 6 columnas) | |
mov x20, #0 // índice general | |
ldr x10, =patron // base del arreglo en x10 | |
fila3x6: | |
mov x21, #0 // columna | |
col3x6: | |
ldrb w22, [x10, x20] | |
add x20, x20, #1 | |
mov x0, #1 | |
ldr x1, =buffer | |
add w22, w22, '0' | |
strb w22, [x1] | |
mov x2, #1 | |
mov x8, #64 | |
svc #0 | |
// espacio entre valores | |
mov x0, #1 | |
ldr x1, =espacio | |
mov x2, #1 | |
mov x8, #64 | |
svc #0 | |
add x21, x21, #1 | |
cmp x21, #6 | |
blt col3x6 | |
// salto de línea | |
mov x0, #1 | |
ldr x1, =newline | |
mov x2, #1 | |
mov x8, #64 | |
svc #0 | |
cmp x20, #18 | |
blt fila3x6 | |
// Imprimir encabezado para patrón 6x3 | |
mov x0, #1 | |
ldr x1, =mensaje2 | |
mov x2, #15 | |
mov x8, #64 | |
svc #0 | |
ldr x11, =patron // base del arreglo para 6x3 | |
mov x30, #0 // fila 0 a 5 | |
fila6x3: | |
mov x29, #0 // columna 0 a 2 | |
col6x3: | |
mov x0, x29 // offset de fila original | |
mov x1, #6 | |
mul x0, x0, x1 // x0 = fila_original * 6 | |
add x0, x0, x30 // x0 += columna_original | |
ldrb w22, [x11, x0] | |
add w22, w22, '0' | |
ldr x1, =buffer | |
strb w22, [x1] | |
mov x0, #1 | |
mov x2, #1 | |
mov x8, #64 | |
svc #0 | |
// espacio | |
mov x0, #1 | |
ldr x1, =espacio | |
mov x2, #1 | |
mov x8, #64 | |
svc #0 | |
add x29, x29, #1 | |
cmp x29, #3 | |
blt col6x3 | |
// salto de línea | |
mov x0, #1 | |
ldr x1, =newline | |
mov x2, #1 | |
mov x8, #64 | |
svc #0 | |
add x30, x30, #1 | |
cmp x30, #6 | |
blt fila6x3 | |
// salir | |
mov x0, #0 | |
mov x8, #93 | |
svc #0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment