Advertisement
Guest User

Assembly

a guest
Dec 18th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. .model tiny
  2. .stack
  3. .data
  4. nr dw ?
  5. mesaj1 db "Introduceti un numar:",10,13,"$"
  6. mesaj2 db "Numarul nu poate incepe cu 0, incercati din nou:",10,13,,"$"
  7. mesaj3 db "Numarul nu poate avea decat cifre, incercati din nou:",10,13,,"$"
  8. mesaj4 db "Numarul introdus este:",10,13,,"$"
  9. .code
  10. main proc
  11. citire:
  12. mov ax,seg mesaj1
  13. mov ds,ax
  14. lea dx,mesaj1
  15. mov ah,09h
  16. int 21h
  17. init:
  18. mov nr,0h
  19. mov bl,10d
  20. mov cx,0000h
  21. mov dx,0000h
  22. jump3:
  23. mov ah,01h
  24. int 21h
  25. mov ah,0h
  26. cmp al,0Dh
  27. je iesire
  28. mov cl,al
  29. mov ax,nr
  30. sub cl,30h
  31. mul bl
  32. add ax,cx
  33. mov nr,ax
  34. call verify
  35. jmp jump3
  36. iesire:
  37. mov ax,seg mesaj4
  38. mov ds,ax
  39. lea dx,mesaj4
  40. mov ah,09h
  41. int 21h
  42. mov ax,nr
  43. mov cx,0h
  44. jump1:
  45. mov dx, 0000h
  46. div bx
  47. push dx
  48. inc cx
  49. cmp ax, 0
  50. jne jump1
  51. jump2:
  52. pop dx
  53. add dx,30h
  54. mov ah,02h
  55. int 21h
  56. loop jump2
  57. mov ah,4ch
  58. int 21h
  59. main endp
  60. verify proc
  61. add cl,30h
  62. cmp ax,39h
  63. jbe numar
  64. ja numar2
  65. numar:
  66. cmp cl,31h
  67. jb eroare1
  68. cmp cl,39h
  69. ja eroare1
  70. jmp jump3
  71. numar2:
  72. cmp cl,30h
  73. jb eroare2
  74. cmp cl,39h
  75. ja eroare2
  76. jmp jump3
  77. eroare1:
  78. mov ax,seg mesaj2
  79. mov ds,ax
  80. lea dx,mesaj2
  81. mov ah,09h
  82. int 21h
  83. jmp init
  84. eroare2:
  85. mov ax,seg mesaj3
  86. mov ds,ax
  87. lea dx,mesaj3
  88. mov ah,09h
  89. int 21h
  90. jmp init
  91. ret
  92. verify endp
  93. end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement