summary refs log tree commit diff
path: root/lisc/test/max.ssa
blob: d5e1d4c78751b584778a5c2c58521da0a6a0c3e3 (plain) (blame)
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
# find the maximum value
# in a nul-terminated array
# of unsigned bytes
#
# b input array
# a output max

@start
@loop
	%max =w phi @start -1, @new %byt, @old %max
	%id0 =l phi @start 0,  @new %id1, @old %id1
	%loc =l add $b, %id0
	%byt =w loadub %loc
	%id1 =l add 1, %id0
	jnz %byt, @iter, @end
@iter
	%cmp =w csle %max, %byt
	jnz %cmp, @new, @old
@new
	jmp @loop
@old
	jmp @loop
@end
	store %max, $a
	ret