Created
January 16, 2025 10:10
-
-
Save thinkphp/dd86d2ba39f34462c5e02aae5b69ec33 to your computer and use it in GitHub Desktop.
Media Aritmetica 8 numere pornind de la adresa simbolica werte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
section .data | |
; aici definim cele 8 numere pornind de la adresa simbolica WERTE | |
werte dd 10, 20, 30, 40, 50, 60, 70, 80 ; poti sa schimbi numerele, nu este nicio problema. | |
count equ 8 ;stabilim numarul de numere in count | |
section .text | |
global _start | |
_start: | |
mov eax, 0 ; initializam suma cu 0 | |
mov ecx, count ; loop counter | |
mov esi, 0 ; array index | |
sum_loop: | |
add eax, [werte + esi*4] ; adunam numarul curent la suma | |
add esi, 1 ; ne deplasam pe urmatorul element din arr | |
loop sum_loop ; decrementam ecx and loop if not zero | |
; acum EAX contine suma | |
; Divide by count (8) to get the mean | |
mov ecx, count | |
cdq ; | |
idiv ecx ; impartim edx:eax by ecx, result in eax | |
; Acuma EAX contine media aritmetica | |
mov ebx, eax ; pune rezultatul în ebx pentru codul de output | |
mov eax, 1 ; system call pentru exit | |
int 0x80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment