SHARE
TWEET

Untitled

a guest May 13th, 2019 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .data
  2.         SYSEXIT = 60
  3.         EXIT_SUCCESS = 0
  4.         STDIN = 0
  5.         STDOUT = 1
  6.         SYSWRITE = 1
  7.         SYSREAD = 0
  8.         BUFLEN = 100
  9.  
  10. .bss
  11.         .comm input, 100
  12.         .comm output, 100
  13.  
  14. .text
  15. .global main
  16. main:
  17.        
  18.         movq $SYSREAD, %rax
  19.         movq $STDIN, %rdi
  20.         movq $input, %rsi
  21.         movq $BUFLEN, %rdx
  22.         syscall
  23.  
  24.        
  25.         movq %rax, %rdx
  26.         dec %rdx
  27.         movq %rdx, %r8
  28.         dec %r8
  29.        
  30.         movq $0, %rdi
  31.        
  32. petla:
  33.         movq $0, %rbx
  34.         movb input(,%rdi,1), %bl
  35.         movb %bl, output(, %r8, 1)      
  36.         inc %rdi
  37.         dec %r8
  38.         cmp %rdx, %rdi  
  39.         jl petla
  40.         movb $'\n', output(,%rdi,1)
  41.  
  42.         movq $SYSWRITE, %rax
  43.         movq $STDOUT, %rdi
  44.         movq $output, %rsi
  45.         movq $BUFLEN, %rdx
  46.         syscall
  47.  
  48.         movq $SYSEXIT, %rax
  49.         movq $EXIT_SUCCESS, %rdi
  50.         syscall
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