Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bits 32
  2. global start
  3. extern exit; tell nasm that exit exists even if we won't be defining it
  4. import exit msvcrt.dll; exit is a function that ends the calling process. It is defined in msvcrt.dll
  5. ; our data is declared here (the variables  needed by our program)
  6. segment data use32 class=data
  7.     sir db 'bcdefgha'
  8.     len equ ($-sir);lungimea sirului (in dublucuvinte)
  9.    swap db 0
  10. ; our code starts here
  11. segment code use32 class=code
  12.    start:
  13.        mov esi, 0
  14.        comparison:
  15.            mov al, [sir + esi]
  16.            cmp al, [sir + esi+ 1]
  17.            jb noswap
  18.                mov dl, [sir+esi+1]
  19.                mov [sir+esi+1], al
  20.                mov [sir+esi], dl
  21.  
  22.                mov byte[swap], 1
  23.            noswap:
  24.            add esi, 1
  25.            cmp esi, len-1
  26.            jnz comparison
  27.              
  28.            cmp byte[swap], 0
  29.            jnz start
  30.        push dword 0; push the parameter for exit onto the stack
  31.        call [exit]; call exit to terminate the program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement