Guest User

for gaile -- sec anon ops

a guest
May 8th, 2012
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; reverse string
  2.  
  3. name "reverse"
  4.  
  5. org 100h
  6.  
  7. jmp start
  8.  
  9. ; when reversed it will be a readable string,
  10. ; '$' marks the end of the string:
  11. string1 db 'abcde$'  
  12.  
  13. start:      lea bx, string1
  14.  
  15.             mov si, bx
  16.  
  17. next_byte:  cmp [si], '$'
  18.             je found_the_end
  19.             inc si
  20.             jmp next_byte
  21.  
  22. found_the_end:  dec si
  23.  
  24. ; now bx points to beginning,
  25. ; and si points to the end of string.
  26.  
  27.  
  28. ; do the swapping:
  29.  
  30. do_reverse: cmp bx, si
  31.             jae done
  32.            
  33.             mov al, [bx]
  34.             mov ah, [si]
  35.            
  36.             mov [si], al
  37.             mov [bx], ah
  38.            
  39.             inc bx
  40.             dec si
  41. jmp do_reverse
  42.  
  43.  
  44.  
  45. ; reverse complete, print out:
  46. done:       lea dx, string1
  47.             mov ah, 09h
  48.             int 21h
  49.  
  50. ; wait for any key press....
  51. mov ah, 0
  52. int 16h
  53.  
  54. ret
Advertisement
Add Comment
Please, Sign In to add comment