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 ; exit is a function that ends the calling process. It is defined in msvcrt.dll
- import printf 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
- ; ...Se da un sir de octeti S. Sa se construiasca sirul D ale carui elemente reprezinta suma fiecaror doi octeti consecutivi din sirul S.
- sursa db 1,2,3,4,5,6
- ls equ ($-sursa)
- dest TIMES ls db 0
- format db "Sirul este: ",0
- format2 db "%d ",0
- ; our code starts here
- segment code use32 class=code
- start:
- ; ...
- mov esi,0
- mov al,[sursa+esi]
- mov edi,0
- inc esi
- for_sir:
- cmp esi,ls
- je end_for
- mov bl,[sursa+esi]
- add al,bl
- mov [dest+edi],al
- inc edi
- inc esi
- mov al,bl
- jmp for_sir
- end_for:
- push dword format
- call[printf]
- add esp, 4*1
- mov esi,0
- repeta:
- cmp esi,ls-1
- je final
- pushad
- mov al,[dest+esi]
- cbw
- cwde
- push eax
- push dword format2
- call [printf]
- add esp, 4*2
- popad
- add esi,1
- jmp repeta
- final:
- ; exit(0)
- 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