Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- section .text
- global _start
- _start:
- ; Set elements of array
- mov ECX, 30 ; Set number of iterations to ECX
- setElement: mov EAX, 2 ; 2
- imul ECX ; 2*i
- add EAX, 10 ; 2*i+10
- idiv ECX ; (2*i+10)/i
- sub EAX, ECX ; (2*i+10)/i-i
- mov [array+ECX-1], EAX; Sets the i element to the array
- loop setElement ; Goto setElement with i-1
- ; Print elements of array
- mov ECX, 30 ; Sets ECX value (counter) for loop
- mov EAX, 4 ; System call number (sys_write)
- mov EBX, 1 ; File descriptor (stdout)
- mov EDX, 4 ; Size of message
- printElements: push ECX ; Stores ECX value (counter) in stack
- lea ECX, [array+ECX-1]; Gets value of array
- int 0x80 ; Print 32-bit value
- pop ECX ; Restores ECX value (counter) from stack
- loop printElements; ; Repeat while ECX greater than zero
- ; Call to exit
- mov EAX,1
- int 0x80
- section .data
- array times 30 dd 0 ; Allocate 30 elements of Double Word
Advertisement
Add Comment
Please, Sign In to add comment