SHARE
TWEET

print

a guest Nov 12th, 2019 134 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @ ex10-2.s
  2. @ Enter four characters and echo
  3. .syntax unified
  4. .cpu cortex-a53
  5. .fpu neon-fp-armv8
  6.  
  7. @ Constants
  8. .equ STDOUT, 1
  9. .equ STDIN, 0
  10. .equ msg, 9    @ Inici del missatge en la pila
  11. .equ lenr, 4
  12. .equ lenw, 5    @ Afegeixo nova linia
  13. .equ EOL, '\n'
  14.  
  15. .text
  16. .global main
  17. main:@ ex10-2.s
  18. @ Enter four characters and echo
  19. .syntax unified
  20. .cpu cortex-a53
  21. .fpu neon-fp-armv8
  22.  
  23. @ Constants
  24. .equ STDOUT, 1
  25. .equ STDIN, 0
  26. .equ msg, 9    @ Inici del missatge en la pila
  27. .equ lenr, 4
  28. .equ lenw, 5    @ Afegeixo nova linia
  29. .equ EOL, '\n'
  30.  
  31. .text
  32. .global main
  33. main:
  34.     stmdb sp!, {fp, lr}    @ Deso fp i lr a la pila
  35.     add fp, sp, 4          @ Apunto fp a la base de la pila
  36.     sub sp, sp, 8          @ Reservo espai per 4 bytes
  37.  
  38.     mov r0, STDIN
  39.     sub r1, fp, msg     @ Direccio de memoria on desar els caracters
  40.     mov r2, lenr        @ Nombre de caracters per llegir
  41.     bl read
  42.  
  43.     sub r0, fp, 5      @ Ultim caracter
  44.     mov r1, EOL
  45.     strb r1, [r0]      @ Nova linia
  46.     mov r0, STDOUT     @ Preparo per llegir
  47.     sub r1, fp, msg    @ Carrego la direccio del missatge
  48.     mov r2, lenw
  49.     bl write
  50.  
  51.     add sp, sp, 8      @ Recupero el punter de pila
  52.     ldmia sp!, {fp, lr}
  53.  
  54.     bx lr
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top