Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1.  
  2. ; ex2.asm.
  3.  
  4. .MODEL SMALL
  5. .STACK 100h
  6. .DATA
  7.  
  8. unsignedString DB 13,10, 'The average of the numbers in the array as unsigned is: XXXXX',13,10,'$'
  9. signedString DB 13,10, 'The average of the numbers in the array as signed is: XXXXXX',13,10,'$'
  10. SUM DW ?
  11. myArr DW 0FA0h, 8001h, 150h, 1h, 2h, 3h, 4h, 5h
  12. sizeArr DW 8
  13. Avg DW ?
  14. ten DW 10h
  15.  
  16. .CODE
  17. ProgStart:
  18. MOV AX,@DATA
  19. MOV DS,AX
  20. MOV CX, sizeArr
  21. MOV DI, OFFSET myArr
  22. sum_label:
  23. MOV AX, [DI]
  24. ADD SUM, AX
  25. ADD DI,2
  26. LOOP sum_label
  27.  
  28. average:
  29. MOV AX, SUM
  30. DIV sizeArr
  31. MOV Avg, AX
  32.  
  33. printUNSIGNEDstring:
  34. MOV AX, Avg
  35. MOV DX,0
  36. DIV ten
  37. ADD DL,'0'
  38. MOV unsignedString[62],DL
  39. MOV DX, 0
  40. DIV ten
  41. ADD DL,'0'
  42. MOV unsignedString[61],DL
  43. MOV DX, 0
  44. DIV ten
  45. ADD DL,'0'
  46. MOV unsignedString[60],DL
  47. MOV DX, 0
  48. DIV ten
  49. ADD DL,'0'
  50. MOV unsignedString[59],DL
  51. MOV DX, 0
  52. ADD AL,'0'
  53. MOV unsignedString[58],AL
  54. MOV AH,9
  55. MOV DX,OFFSET unsignedString
  56. INT 21h
  57.  
  58. finish:
  59.  
  60. MOV AH,4Ch
  61. INT 21h
  62. END ProgStart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement