Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Program Description: Mean and Variance
- ; Author: Agis Diamantis
- ; Creation Date: 10/17/19
- ; Revisions: n/a
- ; Date: 10/17/19 Modified by:
- .386
- .model flat,stdcall
- .stack 4096
- ExitProcess proto,dwExitCode:dword
- INCLUDE Irvine32.inc
- .data
- RAW WORD 10,12,8,17,9,22,18,11,23,7,30,22,19,6,7
- Diff WORD 15 DUP(?)
- Square WORD 15 DUP(?)
- printMean BYTE "MEAN",0
- printVariance BYTE "VAR",0
- .code
- main proc
- mov cl,(LENGTHOF RAW) ;loop counter
- mov esi,OFFSET RAW ;esi = 0 index value
- mov ebx, 0
- findSum:
- movzx eax, byte ptr[esi] ;get the value from the array
- add ebx, eax ;add the values of the array
- mov eax,ebx
- add esi, 2 ;increment esi by 2 for WORD array
- loop findSum ;go to findSum repeat until cl=0
- mov edx, OFFSET printMean ;print the mean string
- call WriteString
- mov ecx, (LENGTHOF RAW) ;get the length of the array
- cdq
- idiv ecx ;find Mean value mean = sum/length of the array
- call WriteDec ;print the mean value
- call Crlf
- mov edx, eax
- mov cl(LENGTHOF RAW) ;loop counter
- mov esi,OFFSET RAW ;esi = 0 index value
- mov ebx,0
- ;loop for variance
- Variance:
- movzx eax, byte ptr[esi] ;get the value from the array
- sub eax,edx ;subtract mean value from eax value
- imul eax,eax ;find the square value
- mov eax,ebx
- add esi,2 ;increment esi by 2 for WORD array
- loop Variance ;repeat Variance until cl=0
- mov edx, OFFSET printVariance ;print the variance string
- call WriteString
- mov ecx,(LENGTHOF RAW)
- cdq
- idiv ecx ;find the variance
- call WriteDec ;print the variance
- call Crlf
- invoke ExitProcess,0
- main endp
- end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement