Guest User

Untitled

a guest
Mar 13th, 2017
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. section     .text
  2. global      _start
  3.  
  4. _start:
  5.  
  6.     ; Set elements of array
  7.         mov ECX, 30     ; Set number of iterations to ECX
  8. setElement: mov EAX, 2      ; 2
  9.         imul ECX        ; 2*i
  10.         add EAX, 10     ; 2*i+10
  11.         idiv ECX        ; (2*i+10)/i
  12.         sub EAX, ECX    ; (2*i+10)/i-i
  13.         mov [array+ECX-1], EAX; Sets the i element to the array
  14.         loop    setElement  ; Goto setElement with i-1
  15.  
  16.     ; Print elements of array
  17.         mov ECX, 30     ; Sets ECX value (counter) for loop
  18.         mov EAX, 4      ; System call number (sys_write)
  19.         mov EBX, 1      ; File descriptor (stdout)
  20.         mov EDX, 4      ; Size of message
  21. printElements:  push    ECX     ; Stores ECX value (counter) in stack
  22.         lea ECX, [array+ECX-1]; Gets value of array
  23.         int 0x80        ; Print 32-bit value
  24.         pop ECX     ; Restores ECX value (counter) from stack
  25.         loop    printElements;  ; Repeat while ECX greater than zero
  26.  
  27.     ; Call to exit
  28.         mov EAX,1
  29.         int 0x80
  30.  
  31. section     .data
  32. array   times 30 dd 0           ; Allocate 30 elements of Double Word
Advertisement
Add Comment
Please, Sign In to add comment