Guest User

Untitled

a guest
Jun 24th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. ;Scrivere un programma assembly che:
  2. ;carichi da tastiera un vettore di 9 elementi,ogni elemento e' un digit
  3. ;Inserisca da tastiera una cifra
  4. ;conti le occorrenze della cifra nel vettore
  5. ;stampi a video il numero di occorrenze, se la cifra è presente nel vettore
  6. ;stampi a video il messaggio NON TROVATO, se la cifra non è presente
  7. ;nel vettore
  8.  
  9. ; multi-segment executable file template.
  10.  
  11. data segment
  12. ; add your data here!
  13. pkey db "press any key...$"
  14. msg1 db "inserire 9 elementi:" ,10,13, "$"
  15. msg2 db "inserire il valore da cercare:" ,10,13, "$"
  16. msg3 db "la cifra e' presente per " "volte $",10,13
  17. msg4 db "valore NON TROVATO",10,13
  18. vett db 9(0)
  19. val db (0)
  20. cont db (0)
  21. ends
  22.  
  23. stack segment
  24. dw 128 dup(0)
  25. ends
  26.  
  27. code segment
  28. start:
  29. ; set segment registers:
  30. mov ax, data
  31. mov ds, ax
  32. mov es, ax
  33.  
  34. ; add your code here
  35.  
  36. lea dx,msg1
  37. mov ah,9
  38. int 21h
  39.  
  40. mov si,0
  41. carica:mov ah,1
  42. int 21h
  43. cmp si,09
  44. je fine_carica
  45. mov vett[si],al
  46. inc si
  47. jmp carica
  48.  
  49.  
  50.  
  51. fine_carica: lea dx,msg2
  52. mov ah,9
  53. int 21h
  54.  
  55. xor ax,ax
  56.  
  57. mov ah,1
  58. int 21h
  59. mov val,al
  60.  
  61. mov si,0
  62.  
  63.  
  64. controllo:cmp vett[si],al
  65. je incrementa_vett
  66. inc cont
  67. jmp controllo
  68.  
  69. incrementa_vett:
  70. inc si
  71. jmp controllo
  72.  
  73. lea dx, pkey
  74. mov ah, 9
  75. int 21h ; output string at ds:dx
  76.  
  77. ; wait for any key....
  78. mov ah, 1
  79. int 21h
  80.  
  81. mov ax, 4c00h ; exit to operating system.
  82. int 21h
  83. ends
  84.  
  85. end start ; set entry point and stop the assembler.
Add Comment
Please, Sign In to add comment