Advertisement
Guest User

Lab5_4

a guest
Mar 29th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. .486
  2. .model flat, stdcall
  3. INCLUDE stdlib.inc
  4. INCLUDELIB msvcrt.lib
  5.  
  6. .DATA
  7. string db "0000", 0
  8. leng dd ?
  9. res db ?, 0
  10.  
  11. .CODE
  12. main:
  13. mov al, string
  14. mov res, al
  15. mov esi, offset string
  16. mov edi, offset res
  17. mov leng, 0
  18.  
  19. calculateLength: ; считаем длину массива
  20. cmp byte ptr [esi], 0
  21. je prepare
  22. inc leng
  23. inc esi
  24. jmp calculateLength
  25.  
  26. prepare:
  27. mov esi, offset string ; начало исходной строки
  28. mov ebx, leng
  29. add ebx, esi
  30. dec ebx
  31. mov esi, ebx ; теперь ее конец
  32. mov edi, offset res ; начало результата
  33. jmp start
  34.  
  35. start:
  36. cmp esi, offset string
  37. je ending
  38. cmp byte ptr [esi], 48
  39. je incIndex
  40. mov bh, [esi]
  41. mov [edi], bh
  42. dec esi
  43. inc edi
  44. jmp start
  45.  
  46. decIndex:
  47. dec esi
  48. jmp start
  49.  
  50. ending:
  51. mov bh, [esi]
  52. mov [edi], bh
  53.  
  54. call exit
  55. END main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement