	cpu LMM
	.module selftest.c
	.area text(rom, con, rel)
	.dbfile ./selftest.c
	.dbfunc e selftest _selftest fc
;         trials -> X+0
_selftest::
	.dbline -1
	push X
	mov X,SP
	add SP,1
	.dbline 5
; #include "slave.h"
; #include "main.h"
; 
; unsigned char selftest(void)
; {
	.dbline 8
; 	unsigned char trials;
; 	
; 	for (trials=0;trials<3;trials++)
	mov [X+0],0
	xjmp L5
L2:
	.dbline 9
; 	{
	.dbline 10
; 		slavestate[0]=0;
	mov REG[0xd0],>_slavestate
	mov [_slavestate],0
	.dbline 12
; 		
; 		slave_requeststate();
	xcall _slave_requeststate
	.dbline 14
; 	
; 		if (slavestate[0]==0xED && slavestate[1]>30)
	mov REG[0xd0],>_slavestate
	cmp [_slavestate],-19
	jnz L6
	mov A,30
	cmp A,[_slavestate+1]
	jnc L6
X0:
	.dbline 15
; 			return 1;
	mov REG[0xd0],>__r0
	mov A,1
	xjmp L1
L6:
	.dbline 16
L3:
	.dbline 8
	inc [X+0]
L5:
	.dbline 8
	cmp [X+0],3
	jc L2
X1:
	.dbline 19
; 	}
; 	
; 	// DO THIS!
; 	return 0;
	mov REG[0xd0],>__r0
	mov A,0
	.dbline -2
L1:
	add SP,-1
	pop X
	.dbline 0 ; func end
	ret
	.dbsym l trials 0 c
	.dbend
