linux - this program is incomplete but I'm supposed to ask the user for 10 2-digit numbers and then give the average -


however segmentation fault don't know means , how approach either can please explain?

   segment .data         ;welcome message         welcomemsg      db      "this nasm program calculates average of 10 2-digit  numbers", 0xa         msglength       equ     $-welcomemsg         endingmsg       db      "the average is: ", 0xa         endinglength    equ     $-endingmsg         numbers         db      "enter 10 2-digit numbers",0xa         numberslength   equ     $-numbers  segment .bss arrayofnumber: resb 30 ;store number entered user in arrayofnumber    arrayofnumberlength equ $-arrayofnumber total :         resw 1 ; store sum value of 10 numbers segment .text          global _start _start:         mov eax, 4      ;write()         mov ebx, 1      ;where? output         mov ecx, welcomemsg ; want output         mov edx, msglength  ; length of welcomemsg         int 0x80         mov eax, 4         mov ebx, 1         mov ecx, numbers         mov edx, numberslength         int 0x80         ;accept input , store arrayofnumber         sub esi, esi         mov esi, 10 loop1:         mov eax, 3      ;read          mov ebx, 0      ; standard input(keyboard/console)         mov ecx, arrayofnumber ; storing @ memory location arrayofnumber         mov edx, 3      ;3 bytes         int 0x80         dec esi         jnz loop1       ;if esi not equal 0 goto loop1         sub esi, esi         sub edi,edi         sub ecx, ecx         sub ebx, ebx loop2:         sub eax, eax         mov eax, [arrayofnumber+edi]         sub eax, 30         add edi, 1         imul eax, 10         mov ebx, [arrayofnumber+edi]         sub ebx, 30         add edi, 2         add ebx, eax         add ecx, ebx         cmp edi, 30   jne loop2          sub edi, edi         mov [total], ecx         mov edi, 2         mov ax, [total] convert:         mov bx, 10         sub dx, dx         div bx         add dl, '0'         mov [total + edi], dl         dec edi         cmp ax, 0         jne convert print:         mov eax, 4         mov ebx, 1         mov ecx, total         mov edx, 3         int 0x80         mov eax, 1         mov ebx, 0          int 0x80 

this whole program , output of no longer have segmentation fault not right sum of these following numbers.

this nasm program calculates average of 10 2-digit numbers enter 10 2-digit numbers 12 12 12 12 12 12 12 12 12 12 264 should have 120 sum of of these integers not 264. if hep me please.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -