Skip to content

Instantly share code, notes, and snippets.

@ProfAndreaPollini
Created November 16, 2018 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ProfAndreaPollini/493257aecb5f2a9b027eaf928d18b117 to your computer and use it in GitHub Desktop.
Save ProfAndreaPollini/493257aecb5f2a9b027eaf928d18b117 to your computer and use it in GitHub Desktop.
ASSEMBLY: Somma di un vettore di numeri usando https://schweigi.github.io/assembler-simulator/
JMP start
elementi: DB 5
vettore: DB 2
DB 5
DB 10
DB 10
DB 20
start:
MOV A, 0
MOV C, vettore
MOV D, [elementi]
;MOV B, [C+1]
.loop:
ADD A, [C]
INC C
CMP D,1
DEC D
JNZ .loop
HLT
@ProfAndreaPollini
Copy link
Author

Aggiungendo prima di HLT l'istruzione
DIV [elementi]

ottengo la media aritmetica del vettore inserito (media trocata agli interi perchè l'emulatore non gestisce tipi di dati non interi).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment