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 ; 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
- ; 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
- ; ...c+a+b+b+a
- ;a - byte, b - word, c - double word, d - qword - Signed representation
- a db -2
- b dw -5
- c dd 200
- d dq -5000
- v1 resq 1
- ; our code starts here
- segment code use32 class=code
- start:
- ; ...
- mov eax,0
- mov al,[a]
- cbw
- add ax,[b]
- add ax,[b]
- cwde
- add eax,[c]
- mov edx,0
- cdq
- add eax,dword[d+0]
- add edx,dword[d+4]
- mov dword[v1+0],eax
- mov dword[v1+4],edx
- ; 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