-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprog49
44 lines (37 loc) · 880 Bytes
/
prog49
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
--49
.data
prompt: .asciz "Ingrese texto (máximo 100 caracteres): "
result: .asciz "Texto ingresado: %s\n"
buffer: .skip 100
scanfmt: .asciz "%s"
.text
.align 2
.global main
.type main, %function
main:
stp x29, x30, [sp, -16]!
mov x29, sp
// Mostrar prompt
adrp x0, prompt
add x0, x0, :lo12:prompt
bl printf
// Leer entrada
mov x0, #0 // stdin
adrp x1, buffer
add x1, x1, :lo12:buffer
mov x2, #100 // tamaño máximo
mov x8, #63 // sys_read
svc #0
// Agregar null terminator
adrp x1, buffer
add x1, x1, :lo12:buffer
strb wzr, [x1, x0] // x0 contiene bytes leídos
// Mostrar resultado
adrp x0, result
add x0, x0, :lo12:result
adrp x1, buffer
add x1, x1, :lo12:buffer
bl printf
mov w0, #0
ldp x29, x30, [sp], 16
ret