; File test.asm
; generated by the Basic DSP compiler Ver 0.10
; 1999/9/29, 17:52:34.22

; standard program header for the C31 DSK
	.start ".text", 0x809802 ; RAM block 0
	.start ".data", 0x809C00 ; RAM block 1
ten	.set	10	; const ten 10

pi	.set	3.14	; const pi 3.14
g	.set	9.81	; const g  9.81
ii	.set	3	; const ii 3
j0	.set	5	; const j0 5
j1	.set	6	; const j1 6
j2	.set	7	; const j2 7

; start of the data section
	.data
x	.float	0,0,1,6	; var x      float 0,0,1,6
y	.float	0	; var y      float
z	.float	0	; var z      float
zero	.float	0.0	; var zero   float 0.0
array3	.float	0	; var  array3  float 0
array31	.float	1	; var ~array31 float 1
array32	.float	2	; var ~array32 float 2
tab10a	; var  tab10a float(10)
	.loop	10
	.float	0
	.endloop
tab10b	; var  tab10b float(10) 1
	.loop	10
	.float	1
	.endloop
tab20c	; var  tab20c float(10) 1,2
	.loop	10
	.float	1,2
	.endloop
tab20d	; var ~tab20d float(10) 3,4
	.loop	10
	.float	3,4
	.endloop
k	.word	1,2,3,4	; var k      int 1,2,3,4
indice	.word	0	; var indice int
one	.word	1	; var one    int 1
tab10e	; var  tab10e int(10)
	.loop	10
	.word	0
	.endloop
tab10f	; var  tab10f int(10) 1
	.loop	10
	.word	1
	.endloop
tab20g	; var  tab20g int(10) 1,2
	.loop	10
	.word	1,2
	.endloop
tab20h	; var ~tab20h int(10) 3,4
	.loop	10
	.word	3,4
	.endloop
mysub	; var mysub int(2)
	.loop	2
	.word	0
	.endloop
myfsubsrda	.float	0,0,0	; var myfsubsrda float 0,0,0
myisubsrda	.word	0,0,0	; var myisubsrda int   0,0,0
fminsrda	.float	0,0,0	; var fminsrda  float 0,0,0
fmaxsrda	.float	0,0,0	; var fmaxsrda  float 0,0,0

; start of the data address section
_pbase	.word	0x808000 ; memory mapped registers
_x	.word	x	; address of x
_y	.word	y	; address of y
_z	.word	z	; address of z
_zero	.word	zero	; address of zero
_array3	.word	array3	; address of array3
_tab10a	.word	tab10a	; address of tab10a
_tab10b	.word	tab10b	; address of tab10b
_tab20c	.word	tab20c	; address of tab20c
_k	.word	k	; address of k
_indice	.word	indice	; address of indice
_one	.word	one	; address of one
_tab10e	.word	tab10e	; address of tab10e
_tab10f	.word	tab10f	; address of tab10f
_tab20g	.word	tab20g	; address of tab20g
_mysub	.word	mysub	; address of mysub
_myfsubsrda	.word	myfsubsrda	; address of myfsubsrda
_myisubsrda	.word	myisubsrda	; address of myisubsrda
_fminsrda	.word	fminsrda	; address of fminsrda
_fmaxsrda	.word	fmaxsrda	; address of fmaxsrda
_myfsub	.word	myfsub	; address of myfsub

_stack	.word stack	; address of stack
stack	.word $		; beginning of the stack
; end of the data section

; start of the program section
	.entry BEGIN
	.text
BEGIN	ldp	@.data     ; init the data page
	ldi	@stack, sp ; init the stack pointer
main	; :main
	ldi	@_myfsub, R0	; mysub(0) = @myfsub
	ldi	@_mysub, AR1
	sti	R0, *AR1

	ldi	@_myfsubsrda, R0	; mysub(1) = @myfsubsrda
	ldi	@_mysub, AR1
	ldi	1, IR0
	sti	R0, *+AR1(IR0)

	ldi	@_mysub, ar1	; gosub mysub
	ldi	*ar1, r0	; first element is the subroutine address
	push	ar0
	ldi	*+ar1(1), ar0	; second element is the srda address
	callu	r0		; unconditional indirect call
	pop	ar0 

	ldi	@_mysub, ar1	; goto mysub
	ldi	*ar1, r0	; this element is the address
	bu	r0		; unconditional indirect branch

	ldi	@_tab10e, AR1	; if tab10e(j2)>j1 thengoto mysub
	ldi	j2, IR0
	ldi	*+AR1(IR0), R0
	ldi	j1, R1
	ldi	@_mysub, ar1	; the Name after thengoto is a variable
	ldi	*ar1, r2	; this element is the address
	cmpi	R1, R0
	bgt	r2

	ldf	pi, R4	; x0=pi

	ldi	@_x, AR1	; x(ii)=pi
	ldi	ii, IR0
	ldf	pi, R0
	stf	R0, *+AR1(IR0)

	ldi	@_x, AR1; x(ii)*=-1
	ldi	ii, IR0
	negf	*+AR1(IR0), R0
	stf	R0, *+AR1(IR0)

	ldi	@_k, AR1	; k(ii)=ii
	ldi	ii, IR0
	ldi	ii, R0
	sti	R0, *+AR1(IR0)

	ldi	@_k, AR1	; k(ii)+=2
	ldi	ii, IR0
	ldi	2, R0
	addi3	R0, *+AR1(IR0), R0
	sti	R0, *+AR1(IR0)

	ldi	@_k, AR1	; k(ii)*=-1
	ldi	ii, IR0
	negi	*+AR1(IR0), R0
	sti	R0, *+AR1(IR0)

	ldi	@_tab10a, AR1	; tab10a(j0)+=tab10a(j1)*tab10a(j2)
	ldi	j1, IR0
	ldf	*+AR1(IR0), R0
	ldi	j2, IR0
	ldf	*+AR1(IR0), R1
	mpyf3	R1, R0, R0
	ldi	j0, IR0
	addf3	R0, *+AR1(IR0), R0
	stf	R0, *+AR1(IR0)

	ldi	@_tab10a, AR1	; if tab10a(j2)>tab10a(j0) thengoto main
	ldi	j2, IR0
	ldf	*+AR1(IR0), R0
	ldi	j0, IR0
	ldf	*+AR1(IR0), R1
	cmpf	R1, R0
	bgt	main

	ldi	@_tab10e, AR1	; if tab10e(j2)>j1 thengoto main
	ldi	j2, IR0
	ldi	*+AR1(IR0), R0
	ldi	j1, R1
	cmpi	R1, R0
	bgt	main

	ldf	3, R4	; x0=3

	ldf	3, R0	; x0+=3
	addf3	R0, R4, R4

	ldf	5, R0	; x0*=5
	mpyf3	R0, R4, R4

	ldf	-9, R0	; x1!=-9
	absf	R0, R5

	ldf	R4, R0	; x=x0+x1
	ldf	R5, R1
	addf3	R1, R0, R0
	ldi	@_x, AR1
	stf	R0, *AR1

	ldi	@_x, AR1	; x2=x
	ldf	*AR1, R0
	ldf	R0, R6

	ldf	R4, R0	; x2+=x0*x1
	ldf	R5, R1
	mpyf3	R1, R0, R0
	addf3	R0, R6, R0
	ldf	R0, R6

	ldi	5, R4	; i0=5

	ldi	3, R0	; i0+=3
	addi3	R0, R4, R4

	ldi	2, R0	; i0*=2
	mpyi3	R0, R4, R4

	ldi	-4, R0	; i1!=-4
	absi	R0, R5

	ldi	R4, R0	; k=i0+i1
	ldi	R5, R1
	addi3	R1, R0, R0
	ldi	@_k, AR1
	sti	R0, *AR1

	ldi	@_k, AR1	; i2=k
	ldi	*AR1, R0
	ldi	R0, R6

	ldi	R4, R0	; i2+=i0*i1
	ldi	R5, R1
	mpyi3	R1, R0, R0
	addi3	R0, R6, R0
	ldi	R0, R6

	ldi	@_x, AR1	; x=3
	ldf	3, R0
	stf	R0, *AR1

	ldi	@_x, AR1	; x+=3
	ldf	3, R0
	addf3	R0,*AR1, R0
	stf	R0, *AR1

	ldi	@_x, AR1	; x*=5
	ldf	5, R0
	mpyf3	R0,*AR1, R0
	stf	R0, *AR1

	ldi	@_x, AR1	; x-= 1
	ldf	1, R0
	subf3	R0,*AR1, R0
	stf	R0, *AR1

	ldi	@_y, AR1	; y=2
	ldf	2, R0
	stf	R0, *AR1

	ldi	@_z, AR1	; z=3
	ldf	3, R0
	stf	R0, *AR1

	ldi	@_y, AR1	; x+=y*z
	ldf	*AR1, R0
	ldi	@_z, AR1
	ldf	*AR1, R1
	mpyf3	R1, R0, R0
	ldi	@_x, AR1
	addf3	R0, *AR1, R0
	stf	R0, *AR1

	ldi	@_indice, AR1	; indice=1
	ldi	1, R0
	sti	R0, *AR1

	ldi	@_x, AR1	; x(indice)=1.5
	ldi	@_indice, AR2
	ldf	1.5, R0
	ldi	*AR2, IR0
	stf	R0, *+AR1(IR0)

	ldi	@_x, AR1	; x(indice)+=3
	ldi	@_indice, AR2
	ldf	3, R0
	ldi	*AR2, IR0
	addf3	R0, *+AR1(IR0), R0
	stf	R0, *+AR1(IR0)

	ldi	@_x, AR1	; x(indice)*=5
	ldi	@_indice, AR2
	ldf	5, R0
	ldi	*AR2, IR0
	mpyf3	R0, *+AR1(IR0), R0
	stf	R0, *+AR1(IR0)

	ldi	@_x, AR1	; x(indice)!= -2
	ldi	@_indice, AR2
	ldf	-2, R0
	ldi	*AR2, IR0
	absf	R0, R0
	stf	R0, *+AR1(IR0)

	ldi	2, R4	; i0=2

	ldi	@_x, AR1	; x(i0)+=1
	ldi	R4, IR0
	ldf	1, R0
	addf3	R0, *+AR1(IR0), R0
	stf	R0, *+AR1(IR0)

	ldi	@_x, AR1	; x(i0)*=5
	ldi	R4, IR0
	ldf	5, R0
	mpyf3	R0, *+AR1(IR0), R0
	stf	R0, *+AR1(IR0)

	ldi	@_x, AR1	; x(2)=5.0
	ldi	2, IR0
	ldf	5.0, R0
	stf	R0, *+AR1(IR0)

	ldi	@_x, AR1	; x(2)+=3
	ldi	2, IR0
	ldf	3, R0
	addf3	R0, *+AR1(IR0), R0
	stf	R0, *+AR1(IR0)

	ldi	@_x, AR1	; x(2)-=3
	ldi	2, IR0
	ldf	3, R0
	subf3	R0, *+AR1(IR0), R0
	stf	R0, *+AR1(IR0)

	ldi	@_x, AR1	; x(2)*=5
	ldi	2, IR0
	ldf	5, R0
	mpyf3	R0, *+AR1(IR0), R0
	stf	R0, *+AR1(IR0)

	ldi	@_x, AR1	; x(2)!= -2
	ldi	2, IR0
	ldf	-2, R0
	absf	R0, R0
	stf	R0, *+AR1(IR0)

	ldf	3, R4	; x0=3

	negf	R4, R4; x0 *= -1

	ldi	@_x, AR1	; x=3
	ldf	3, R0
	stf	R0, *AR1

	ldi	@_x, AR1; x*=-1
	negf	*AR1, R0
	stf	R0, *AR1

	ldi	@_x, AR1	; x(1)=1
	ldi	1, IR0
	ldf	1, R0
	stf	R0, *+AR1(IR0)

	ldi	@_x, AR1; x(1)*= -1
	ldi	1, IR0
	negf	*+AR1(IR0), R0
	stf	R0, *+AR1(IR0)

	ldi	@_indice, AR1	; indice=2
	ldi	2, R0
	sti	R0, *AR1

	ldi	@_x, AR1	; x(indice)*=-1
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	negf	*+AR1(IR0), R0
	stf	R0, *+AR1(IR0)

	ldi	2, R4	; i0=2

	ldi	@_x, AR1	; x(i0)*=-1
	ldi	R4, IR0
	negf	*+AR1(IR0), R0
	stf	R0, *+AR1(IR0)

	ldi	@_y, AR1	; x=y+z
	ldf	*AR1, R0
	ldi	@_z, AR1
	ldf	*AR1, R1
	addf3	R1, R0, R0
	ldi	@_x, AR1
	stf	R0, *AR1

	ldi	@_y, AR1	; x(1)+=y(1) * z(1)
	ldi	1, IR0
	ldf	*+AR1(IR0), R0
	ldi	@_z, AR1
	ldi	1, IR0
	ldf	*+AR1(IR0), R1
	mpyf3	R1, R0, R0
	ldi	@_x, AR1
	ldi	1, IR0
	addf3	R0, *+AR1(IR0), R0
	stf	R0, *+AR1(IR0)

	ldi	@_y, AR1	; x(indice)+=y(indice) * z(2)
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	ldf	*+AR1(IR0), R0
	ldi	@_z, AR1
	ldi	2, IR0
	ldf	*+AR1(IR0), R1
	mpyf3	R1, R0, R0
	ldi	@_x, AR1
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	addf3	R0, *+AR1(IR0), R0
	stf	R0, *+AR1(IR0)

	ldi	@_y, AR1	; x(indice)+=y(indice) * y(indice)
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	ldf	*+AR1(IR0), R0
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	ldf	*+AR1(IR0), R1
	mpyf3	R1, R0, R0
	ldi	@_x, AR1
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	addf3	R0, *+AR1(IR0), R0
	stf	R0, *+AR1(IR0)

	ldi	@_y, AR1	; x(indice)+=y(indice) * x(indice)
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	ldf	*+AR1(IR0), R0
	ldi	@_x, AR1
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	ldf	*+AR1(IR0), R1
	mpyf3	R1, R0, R0
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	addf3	R0, *+AR1(IR0), R0
	stf	R0, *+AR1(IR0)

	ldi	@_x, AR1	; x(indice)+=x(indice) * z(indice)
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	ldf	*+AR1(IR0), R0
	ldi	@_z, AR1
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	ldf	*+AR1(IR0), R1
	mpyf3	R1, R0, R0
	ldi	@_x, AR1
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	addf3	R0, *+AR1(IR0), R0
	stf	R0, *+AR1(IR0)

	ldi	@_x, AR1	; x(indice)=x(i0)*z(i1)
	ldi	R4, IR0
	ldf	*+AR1(IR0), R0
	ldi	@_z, AR1
	ldi	R5, IR0
	ldf	*+AR1(IR0), R1
	mpyf3	R1, R0, R0
	ldi	@_x, AR1
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	stf	R0, *+AR1(IR0)

	ldi	@_x, AR1	; x(i2)=x(i0)*z(i1)
	ldi	R4, IR0
	ldf	*+AR1(IR0), R0
	ldi	@_z, AR1
	ldi	R5, IR0
	ldf	*+AR1(IR0), R1
	mpyf3	R1, R0, R0
	ldi	@_x, AR1
	ldi	R6, IR0
	stf	R0, *+AR1(IR0)

	ldi	@_indice, AR1	; indice=1000
	ldi	1000, R0
	sti	R0, *AR1

	ldi	@_indice, AR1	; x=indice
	ldi	*AR1, R0
	float	R0, R0
	ldi	@_x, AR1
	stf	R0, *AR1

	ldi	@_indice, AR1	; x(1)=indice
	ldi	*AR1, R0
	float	R0, R0
	ldi	@_x, AR1
	ldi	1, IR0
	stf	R0, *+AR1(IR0)

	ldi	@_x, AR1	; indice=x
	ldf	*AR1, R0
	fix	R0, R0
	ldi	@_indice, AR1
	sti	R0, *AR1

	ldi	@_indice, AR1	; indice=2
	ldi	2, R0
	sti	R0, *AR1

	ldi	@_zero, AR1	; x(indice)=zero
	ldf	*AR1, R0
	ldi	@_x, AR1
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	stf	R0, *+AR1(IR0)

	ldi	128, R1	; @x=128
	sti	R0, @_x

	ldi	256, R1	; @x *= 256
	ldi	@_x, R0
	mpyi	R1, R0
	sti	R0, @_x

	ldi	156, R1	; @x+= 156
	ldi	@_x, R0
	addi	R1, R0
	sti	R0, @_x

	ldi	256, R1	; @x *=256
	ldi	@_x, R0
	mpyi	R1, R0
	sti	R0, @_x

	ldi	1, R1	; @x+=1
	ldi	@_x, R0
	addi	R1, R0
	sti	R0, @_x

	negi	@_x, R0 ; @x*=-1
	sti	R0, @_x

	ldi	@_y, R0	; @x=@y
	sti	R0, @_x

	ldi	@_y, R0	; @x=@y+one
	ldi	@_one, AR1
	ldi	*AR1, R1
	addi3	R1, R0, R0
	sti	R0, @_x

	ldi	@_x, R0	; @x=@x+@y
	ldi	@_y, R1
	addi3	R1, R0, R0
	sti	R0, @_x

	ldi	1, R1	; @k+=1
	ldi	@_k, R0
	addi	R1, R0
	sti	R0, @_k

	ldi	1, R1	; @k-=1
	ldi	@_k, R0
	subi	R1, R0
	sti	R0, @_k

	ldi	@_k, AR1	; k=5
	ldi	5, R0
	sti	R0, *AR1

	ldi	@_k, AR1	; k(indice)=3
	ldi	@_indice, AR2
	ldi	3, R0
	ldi	*AR2, IR0
	sti	R0, *+AR1(IR0)

	ldi	@_k, AR1	; k(2)*=2
	ldi	2, IR0
	ldi	2, R0
	mpyi3	R0, *+AR1(IR0), R0
	sti	R0, *+AR1(IR0)

	ldi	@_k, AR1	; k(2)-=5
	ldi	2, IR0
	ldi	5, R0
	subi3	R0, *+AR1(IR0), R0
	sti	R0, *+AR1(IR0)

	ldi	@_k, AR1	; k(i0)=4
	ldi	R4, IR0
	ldi	4, R0
	sti	R0, *+AR1(IR0)

	negi	R4, R4; i0 *= -1

	ldi	@_k, AR1; k*=-1
	negi	*AR1, R0
	sti	R0, *AR1

	ldi	@_k, AR1	; k(indice)*=-1
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	negi	*+AR1(IR0), R0
	sti	R0, *+AR1(IR0)

	ldi	@_k, AR1	; k(2)*=-1
	ldi	2, IR0
	negi	*+AR1(IR0), R0
	sti	R0, *+AR1(IR0)

	ldi	@_k, AR1	; k(i0)*=-1
	ldi	R4, IR0
	negi	*+AR1(IR0), R0
	sti	R0, *+AR1(IR0)

	ldi	@_k, AR1	; k=k(1)+k(2)
	ldi	1, IR0
	ldi	*+AR1(IR0), R0
	ldi	2, IR0
	ldi	*+AR1(IR0), R1
	addi3	R1, R0, R0
	sti	R0, *AR1

	ldi	@_k, AR1	; k(1)+=k(1) * k(2)
	ldi	1, IR0
	ldi	*+AR1(IR0), R0
	ldi	2, IR0
	ldi	*+AR1(IR0), R1
	mpyi3	R1, R0, R0
	ldi	1, IR0
	addi3	R0, *+AR1(IR0), R0
	sti	R0, *+AR1(IR0)

	ldi	@_k, AR1	; k(indice)+=k(indice) * k(indice)
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	ldi	*+AR1(IR0), R0
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	ldi	*+AR1(IR0), R1
	mpyi3	R1, R0, R0
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	addi3	R0, *+AR1(IR0), R0
	sti	R0, *+AR1(IR0)

	ldi	@_pbase, AR1	; pbase(21)=51
	ldi	21, IR0
	ldi	51, R0
	sti	R0, *+AR1(IR0)

	ldi	@_indice, AR1; indice*=-1
	negi	*AR1, R0
	sti	R0, *AR1

	ldi	@_k, AR1	; k(2)=-3
	ldi	2, IR0
	ldi	-3, R0
	sti	R0, *+AR1(IR0)

	ldi	@_y, AR1	; y=6.3
	ldf	6.3, R0
	stf	R0, *AR1

myloop	; :myloop
	ldi	@_y, AR1	; y*=2
	ldf	2, R0
	mpyf3	R0,*AR1, R0
	stf	R0, *AR1

	ldi	@_y, AR1	; y+=5
	ldf	5, R0
	addf3	R0,*AR1, R0
	stf	R0, *AR1

	ldi	@_y, AR1	; if y  <=   100 thengoto myloop
	ldf	*AR1, R0
	ldf	100, R1
	cmpf	R1, R0
	ble	myloop

	ldf	R4, R0	; if x0 <= y(i0) thengoto myloop
	ldi	@_y, AR1
	ldi	R4, IR0
	ldf	*+AR1(IR0), R1
	cmpf	R1, R0
	ble	myloop

	ldi	@_x, AR1	; if x(i0) <= y(i1) thengoto myloop
	ldi	R4, IR0
	ldf	*+AR1(IR0), R0
	ldi	@_y, AR1
	ldi	R5, IR0
	ldf	*+AR1(IR0), R1
	cmpf	R1, R0
	ble	myloop

	ldf	R4, R0	; if x0 <= x1    thengoto myloop
	ldf	R5, R1
	cmpf	R1, R0
	ble	myloop

	ldi	@_indice, AR1	; indice+=1
	ldi	1, R0
	addi3	R0, *AR1, R0
	sti	R0, *AR1

	ldi	@_indice, AR1	; indice=0
	ldi	0, R0
	sti	R0, *AR1

	ldi	@_x, AR1	; fminsrda(indice)=x
	ldf	*AR1, R0
	ldi	@_fminsrda, AR1
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	stf	R0, *+AR1(IR0)

	ldi	@_indice, AR1	; indice=1
	ldi	1, R0
	sti	R0, *AR1

	ldi	@_y, AR1	; fminsrda(indice)=y
	ldf	*AR1, R0
	ldi	@_fminsrda, AR1
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	stf	R0, *+AR1(IR0)

	push	ar0	; gosub fmin
	ldi	@_fminsrda, ar0
	call	fmin
	pop	ar0

	ldi	@_fminsrda, AR1	; z=fminsrda(2)
	ldi	2, IR0
	ldf	*+AR1(IR0), R0
	ldi	@_z, AR1
	stf	R0, *AR1

	br	main	; goto main

myfsub	; ::myfsub
	ldi	@_indice, AR1	; indice=1
	ldi	1, R0
	sti	R0, *AR1

	; fsrda*=-1
	negf	*AR0, R0
	stf	R0, *AR0

	; fsrda(1)+=fsrda(0)
	ldf	*AR0, R0
	ldi	1, IR0
	addf3	R0, *+AR0(IR0), R0
	stf	R0, *+AR0(IR0)

	; fsrda(1)*=-1
	ldi	1, IR0
	negf	*+AR0(IR0), R0
	stf	R0, *+AR0(IR0)

	; fsrda(indice)*=-1
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	negf	*+AR0(IR0), R0
	stf	R0, *+AR0(IR0)

	; fsrda=5
	ldf	5, R0
	stf	R0, *AR0

	; fsrda(indice)=3
	ldi	@_indice, AR2
	ldf	3, R0
	ldi	*AR2, IR0
	stf	R0, *+AR0(IR0)

	; fsrda(2)*=2
	ldi	2, IR0
	ldf	2, R0
	mpyf3	R0, *+AR0(IR0), R0
	stf	R0, *+AR0(IR0)

	; if fsrda(i0) >= fsrda(i1) thengoto myfsub
	ldi	R4, IR0
	ldf	*+AR0(IR0), R0
	ldi	R5, IR0
	ldf	*+AR0(IR0), R1
	cmpf	R1, R0
	bge	myfsub

	; if fsrda(1) >= fsrda(2) thengoto myfsub
	ldi	1, IR0
	ldf	*+AR0(IR0), R0
	ldi	2, IR0
	ldf	*+AR0(IR0), R1
	cmpf	R1, R0
	bge	myfsub

	rets	; return

myisub	; :myisub
	ldi	@_indice, AR1	; indice=1
	ldi	1, R0
	sti	R0, *AR1

	; isrda*=-1
	negi	*AR0, R0
	sti	R0, *AR0

	; isrda(1)*=-1
	ldi	1, IR0
	negi	*+AR0(IR0), R0
	sti	R0, *+AR0(IR0)

	; isrda(indice)*=-1
	ldi	@_indice, AR2
	ldi	*AR2, IR0
	negi	*+AR0(IR0), R0
	sti	R0, *+AR0(IR0)

	; isrda=5
	ldi	5, R0
	sti	R0, *AR0

	; isrda(indice)=3
	ldi	@_indice, AR2
	ldi	3, R0
	ldi	*AR2, IR0
	sti	R0, *+AR1(IR0)

	; isrda(2)*=2
	ldi	2, IR0
	ldi	2, R0
	mpyi3	R0, *+AR0(IR0), R0
	sti	R0, *+AR0(IR0)

	; if isrda(i0) >= isrda(i1) thengoto myisub
	ldi	R4, IR0
	ldi	*+AR0(IR0), R0
	ldi	R5, IR0
	ldi	*+AR0(IR0), R1
	cmpi	R1, R0
	bge	myisub

	; if isrda(1) >= isrda(2) thengoto myisub
	ldi	1, IR0
	ldi	*+AR0(IR0), R0
	ldi	2, IR0
	ldi	*+AR0(IR0), R1
	cmpi	R1, R0
	bge	myisub

	rets	; return


; this program uses the xint0 interruption
	.start "xint0sect", 0x809FC5
	.sect  "xint0sect"
	br xint0

	.text
xint0	; :xint0
	reti	; reti

fmin	; :fmin
	ldf	*+ar0(0),r0
	cmpf	*+ar0(1),r0
	ldfp	*+ar0(1),r0
	stf	r0,*+ar0(2)
	rets	; return

fmax	; :fmax
	ldf	*+ar0(0),r0
	cmpf	*+ar0(1),r0
	ldfn	*+ar0(1),r0
	stf	r0,*+ar0(2)
	rets	; return


; end of the program section
	.end
