Guest User

Untitled

a guest
Nov 24th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. string db 'd', 'a', 'b', 'e', 'c', 0Dh, 0Ah, '$'
  2.  
  3. string db 'e', 'c', 'b', 'd', 'a', 0Dh, 0Ah, '$'
  4.  
  5. org 100h
  6.  
  7. jmp main
  8.  
  9. string db 'd', 'a', 'b', 'e', 'c', 0Dh, 0Ah, '$'
  10. length dw 3
  11.  
  12. main:
  13. xor ax, ax
  14. xor bx, bx
  15. xor dx, dx
  16. xor cx, cx
  17. xor si, si
  18. xor bp, bp
  19.  
  20. lea bx, string
  21. mov ax, bx
  22. print "Before string: "
  23. call print_ax_str
  24.  
  25. lea ax, [bx]
  26. push ax
  27.  
  28. lea ax, [bx + 3]
  29. push ax
  30.  
  31. call swap ;swap the chars.
  32.  
  33. lea ax, string
  34. print "After string: "
  35. call print_ax_str
  36. jmp end
  37. swap:
  38. printn "swap!"
  39. push cx
  40. push bx
  41. push dx
  42. push ax
  43. push bp
  44.  
  45.  
  46. mov bp, sp
  47.  
  48. mov ax, [bp + 12]; ax = ptr char 2
  49.  
  50. mov cx, [bp + 14]; cx = ptr char 1
  51.  
  52. mov bx, ax
  53. mov ax, [bx] ;ax = char 2
  54.  
  55. mov bx, cx
  56. mov dx, [bx] ;dx = char 1
  57. mov [bx], ax ;char 1 = char 2
  58.  
  59.  
  60. mov bx, [bp + 12]
  61. mov [bx], dx ;char 2 = char 1
  62. mov ax, [bx]
  63.  
  64. mov sp, bp
  65. pop bp
  66. pop ax
  67. pop dx
  68. pop bx
  69. pop cx
  70. retn 4
  71.  
  72.  
  73. end:
  74. mov ah, 0
  75. int 16h
  76. ret
  77.  
  78. include prints.inc
Add Comment
Please, Sign In to add comment