peon125

asm

Jan 8th, 2017
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. section .text
  2.  
  3. org 100h
  4. start:
  5.  
  6. mov cx, 0h
  7. mov ah, 09h
  8. mov dx, v_give_a_string ;shows "give me a string"
  9. int 21h
  10. giveagain:
  11. call p_giving_a_string ;reads a given letter and counts how many letters a user gave
  12. cmp al, 65
  13. jb j_error_or_ending ;if the user hits enter, program will end
  14. jae j_check_whether_its_a_letter ;if the user types something what is no a letter, program shows an error
  15.  
  16. ending:
  17. mov ax, 4c00h
  18. int 21h
  19.  
  20. j_deleting_stack:
  21. pop bx
  22. cmp bx, 0
  23. je start
  24. jne j_deleting_stack
  25.  
  26. j_error_or_ending:
  27. cmp al, 13
  28. je j_tu
  29. jne j_error
  30.  
  31. j_check_whether_its_a_letter:
  32. cmp al, 90
  33. jbe j_its_a_letter
  34. cmp al, 122
  35. ja j_error
  36. cmp al, 97
  37. jb j_error
  38.  
  39. j_its_a_letter:
  40. push ax
  41. jmp giveagain
  42.  
  43. j_error:
  44. mov ah, 09h
  45. mov dx, v_thats_an_error_dude
  46. int 21h
  47. jmp j_deleting_stack
  48.  
  49. j_tu:
  50. mov ax, 2
  51. mul cx
  52. mov si, 0
  53.  
  54. j_change_cases: ;i think that is the segment, where i got a problem
  55. mov ax, [bp + si]
  56. add si, 2
  57. cmp ax, 0
  58. je ending
  59. cmp ax, 95
  60. jb j_uppercase
  61. ja j_lowercase
  62.  
  63. j_uppercase:
  64. sub ax, 32
  65. mov ah, 02h
  66. mov dx, ax
  67. int 21h
  68. jmp j_change_cases
  69.  
  70. j_lowercase:
  71. sub ax, 32
  72. mov ah, 02h
  73. mov dx, ax
  74. int 21h
  75. jmp j_change_cases
  76.  
  77. p_giving_a_string:
  78. mov ah, 01h
  79. int 21h
  80. inc cx
  81. ret
  82.  
  83. section .data
  84. v_give_a_string db 10, "give me a string: $", 10
  85. v_thats_an_error_dude db 10, "thats not what we wanted. try again sweetie $", 10
Advertisement
Add Comment
Please, Sign In to add comment