Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bits 32 ; assembling for the 32 bits architecture
- ; declare the EntryPoint (a label defining the very first instruction of the program)
- global start
- ; declare external functions needed by our program
- extern exit,printf ; tell nasm that exit exists even if we won't be defining it
- import exit msvcrt.dll
- import printf msvcrt.dll ; exit is a function that ends the calling process. It is defined in msvcrt.dll
- ; msvcrt.dll contains exit, printf and all the other important C-runtime specific functions
- ; our data is declared here (the variables needed by our program)
- segment data use32 class=data
- s dw 01h,0f303h,05h,07h ; ...
- l equ ($-s)/2
- d resb l
- format db '%d ',0
- ;s=01 00 , 03 f3, 05 00,07 00
- ; our code starts here
- segment code use32 class=code
- start:
- mov esi,1
- mov edi,0
- for_sir:
- cmp esi,l
- jae end_for
- mov al,[s+esi]
- cmp al,0
- jns pas_urmator
- mov [d+edi],al
- inc edi
- pas_urmator:
- add esi, 2
- jmp for_sir
- end_for:
- mov esi,0
- repeta:
- cmp esi,edi
- je final
- mov al,[d+esi]
- cbw
- cwde
- push eax
- push dword format
- call [printf]
- add esp, 4*2
- add esi,1
- jmp repeta
- final:
- push dword 0 ; push the parameter for exit onto the stack
- call [exit] ; call exit to terminate the program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement