File: max.apoo

package info (click to toggle)
apoo 2.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 444 kB
  • ctags: 264
  • sloc: python: 1,954; perl: 67; makefile: 56; sh: 4
file content (63 lines) | stat: -rw-r--r-- 518 bytes parent folder | download | duplicates (5)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# maximum of a sequence of N values

N:	const 	10
val:	const	7
	const	8
	const	20
	const	43
	const	15
	const	70
	const	18
	const	71	
	const	52

	const	83
	const	1
MAX:	mem	1
	#R4=maximum; R2=index
	load	N	R1
	loadn	val	R2
	loadi	R2	R4
loop:	inc	R2
	dec	R1
	jzero	R1 	cont
	#puts the next value in  R3 
	loadi	R2	R3
	# copy before comparing with max
	storer	R3	R5
	sub	R4	R5
	# if R4-R5 > 0 continue
	jpos	R5	loop
	#max gets a new value
	storer 	R3	R4
	jump	loop	
cont:	store	R4	MAX
	halt