Advertisement
Guest User

nextInstruction problem

a guest
Nov 15th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. ; multi-segment executable file template.
  2.  
  3. data segment
  4. ; add your data here!
  5. pkey db "press any key...$"
  6. vnesiString db "vnesi string:$"
  7. string1 db ?
  8. string2 db ?
  9. string1Size db 0
  10. string2Size db 0
  11. stringSize db 0
  12. nextInstruction dw 0
  13. ends
  14.  
  15. stack segment
  16. dw 128 dup(0)
  17. ends
  18.  
  19. code segment
  20.  
  21. transform proc
  22. pop dx ; next instruction is popped
  23. mov nextInstruction, dx
  24. pop ax ; size of the string
  25. mov stringSize, al
  26. pop bx ; effective address of the string
  27. mov ch, 0d
  28. mov cl, stringSize
  29. dec cx ; not to read the last '$'
  30.  
  31. tr:
  32. cmp [bx], 65d
  33. jle smallLetter
  34. cmp [bx], 90
  35. jge smallLetter
  36. add [bx], 32d
  37. smallLetter:
  38. inc bx
  39. loop tr
  40.  
  41. mov dx, nextInstruction
  42. push dx
  43. ret
  44. transform endp
  45.  
  46. ;;;;
  47. ;;;;
  48. ;;;;
  49.  
  50. enterString proc
  51. pop dx ; this is next instruction
  52. mov nextInstruction, dx
  53. mov ax, nextInstruction
  54. pop bx ; this is effective address of the string
  55. mov cx, 50d
  56.  
  57. inputS:
  58. mov ah, 1h
  59. int 21h
  60. cmp al, 36d
  61. je stringEntered
  62. mov ah, 0d
  63. mov [bx], ax
  64. inc bx
  65. inc stringSize
  66. loop inputS
  67.  
  68. stringEntered:
  69. mov ah, 0d
  70. mov [bx], al
  71. mov ax, dx
  72. mov dx, nextInstruction
  73. push dx ;return next instruction
  74. ret
  75. enterString endp
  76.  
  77. start:
  78. ; set segment registers:
  79. mov ax, data
  80. mov ds, ax
  81. mov es, ax
  82.  
  83. ; add your code here
  84.  
  85. lea dx, vnesiString
  86. mov ah, 9
  87. int 21h
  88.  
  89.  
  90. mov bx, OFFSET string1
  91. push bx
  92. call enterString
  93.  
  94. mov al, stringSize
  95. mov string1Size, al
  96. mov stringSize, 0d
  97. lea dx, vnesiString
  98. mov ah, 9
  99. int 21h
  100.  
  101. mov bx, OFFSET string2
  102. push bx
  103. call enterString
  104. mov al, stringSize
  105. mov string2Size, al
  106. mov stringSize, 0d
  107. ; here we have entered 2 strings
  108. mov al, string1Size
  109. mov dl, string2Size
  110.  
  111.  
  112.  
  113. mov bx, OFFSET string1
  114. mov ah, 0d
  115. mov al, string1Size
  116. push bx
  117. push ax
  118. call transform
  119.  
  120. ; test
  121. mov dl, 10d
  122. mov ah, 2h
  123. int 21h
  124.  
  125. lea dx, string1
  126. mov ah, 9
  127. int 21h
  128.  
  129.  
  130.  
  131.  
  132. mov ax, 4c00h ; exit to operating system.
  133. int 21h
  134. ends
  135.  
  136. end start ; set entry point and stop the assembler.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement