mad1231999

Untitled

Apr 26th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.22 KB | None | 0 0
  1. section .bss
  2. answer  resb    1
  3.  
  4. section .text
  5. global _start
  6.  
  7. _start:
  8.         ; read one byte of data from stdin
  9.         mov     eax, 0x03       ; sys_read
  10.         mov     ebx, 0x00       ; stdin
  11.         mov     ecx, answer
  12.         mov     edx, 0x01
  13.         int     0x80
  14.  
  15.         ; counter
  16.         mov     cx, [answer]
  17.         sub     cx, 0x30        ; get non-ascii value
  18.  
  19.         loop_start:
  20.                 add     cx, 0x30
  21.                 push    cx       ; push ascii value
  22.  
  23.                 ; write the current counter value
  24.                 mov     eax, 0x04
  25.                 mov     ebx, 0x01
  26.                 mov     ecx, esp
  27.                 mov     edx, 0x01
  28.                 int     0x80
  29.  
  30.                 ; check if the loop is done
  31.                 pop     cx
  32.                 sub     cx, 0x30
  33.                 dec     cx
  34.                 cmp     cx, 0x00
  35.                 jge     loop_start
  36.  
  37.         ; write newline
  38.         push    0x0a
  39.         mov     eax, 0x04
  40.         mov     ebx, 0x01
  41.         mov     ecx, esp
  42.         mov     edx, 0x01
  43.         int     0x80
  44.  
  45.         ; exit program
  46.         mov     eax, 0x01       ; sys_exit
  47.         mov     ebx, 0x00       ; no file descriptor
  48.         int     0x80
Advertisement
Add Comment
Please, Sign In to add comment