code_junkie

A Simple Assembly Input Question

Nov 14th, 2011
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. BITS 32
  2. global _main
  3. section .data
  4.  
  5. prompt db "Enter a string: ", 13, 10, '$'
  6. input resd 1 ; something I can using to store the users input.
  7.  
  8. name db "Name: ******", 13, 10,'$'
  9. StudentID db "********", 13, 10, '$'
  10. InBoxID db "*************", 13, 10, '$'
  11. Assignment db "************", 13, 10, '$'
  12. version db "***************", 13, 10, '$'
  13.  
  14. section .text
  15. _main:
  16.  
  17. mov ah, 9
  18. mov edx, prompt
  19. int 21h
  20. mov ah, 08h
  21. while:
  22. int 21h
  23. ; some code that should store the input.
  24. mov [input], al
  25. cmp al, 13
  26. jz endwhile
  27. jmp while
  28. endwhile:
  29.  
  30. mov ah, 9
  31. ; displaying the input.
  32.  
  33. mov edx, name
  34. int 21h
  35. mov edx, StudentID
  36. int 21h
  37. mov edx, InBoxID
  38. int 21h
  39. mov edx, Assignment
  40. int 21h
  41. mov edx, version
  42. int 21h
  43. ret
  44.  
  45. ; For each string already padded with 13, 10, $
  46. ; at the end, use the following:
  47. mov ah, 08h
  48. mov edi, string
  49. mov ecx, max_chars
  50. cld
  51. while:
  52. int 21h
  53. stosb ; store the character and increment edi
  54. cmp ecx, 1 ; have we exhausted the space?
  55. jz out
  56. dec ecx
  57. cmp al, 13
  58. jz terminate ; pad the end
  59. jmp while
  60. terminate:
  61. mov al, 10
  62. stosb
  63. mov al, '$'
  64. stosb
  65. out:
  66. ; you can ret here if you wish
Add Comment
Please, Sign In to add comment