forked from mdbGalvan/DAA_P01
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.ram
35 lines (35 loc) · 963 Bytes
/
test2.ram
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
; Lee de la cinta de entrada un n£mero "n"
; A continuaci¢n lee "n" n£meros y los almacena en el array
; Multiplica cada elemento del array por si mismo.
READ 1 ; leer n <- r1
LOAD =3 ; j <- r2
STORE 2
READ *2 ; lee a[0] <- r3
LOAD 1 ; n = n - 1
SUB =1
STORE 1
test: LOAD 1
JZERO endwhile ; si n = 0;
LOAD 2 ; j = j + 1
ADD =1
STORE 2
READ *2 ; se lee a[i]
LOAD 1 ; n = n - 1
SUB =1
STORE 1
JUMP test
endwhile: LOAD =3
STORE 1
condition:LOAD =6
SUB 1
JZERO endw
LOAD 1
STORE 2
LOAD *2
MULT *2
STORE *2
LOAD 1
ADD =1
STORE 1
JUMP condition
endw: HALT ;hola que tal