#ifndef ASM
#define ASM
#endif
#include <vs1005h.h>
#include <vstypes.h>

	.export _XRomTestC
	.export _YRomTestC

	.sect code,IRomTestC
	.export _IRomTestC
_IRomTestC:
	ldx (i6)+1,null
	stx lc,(i6)+1;	sty b1,(i6)
	stx le,(i6);	sty ls,(i6)

	add b0,ones,b0
	add b0,ones,b0
	
	loop b0,$0-1
	and a,null,a

	lsl a0,a0	; ldi (i0)+1,b
	lslc a1,a1 		//updates guard bits!
	xor a,b,a ; mv a2,b0 // 0 or 0xffff = POLY
	xor a0,b0,a0
$0:
	ldx (i6)-1,le;	ldy (i6),ls
	jr
	ldx (i6)-1,lc;	ldy (i6),b1


	.sect code,XRomTestC
	.export _XRomTestC
_XRomTestC:
	ldx (i6)+1,null
	stx lc,(i6)+1;	sty b1,(i6)
	stx le,(i6);	sty ls,(i6)

	add b0,ones,b0
	add b0,ones,b0
	add b0,ones,b0
	
	loop b0,$0-1
	and a,null,a

	lsl a0,a0	; ldx (i0)+1,b0
	lslc a1,a1		//updates guard bits!
	xor a0,b0,a0 ; mv a2,b0 // 0 or 0xffff
	xor a0,b0,a0
$0:
	ldx (i6)-1,le;	ldy (i6),ls
	jr
	ldx (i6)-1,lc;	ldy (i6),b1


	.sect code,YRomTestC
	.export _YRomTestC
_YRomTestC:
	ldx (i6)+1,null
	stx lc,(i6)+1;	sty b1,(i6)
	stx le,(i6);	sty ls,(i6)

	add b0,ones,b0
	add b0,ones,b0
	add b0,ones,b0
	loop b0,$0-1
	and a,null,a

	lsl a0,a0	; ldy (i0)+1,b0
	lslc a1,a1		//updates guard bits!
	xor a0,b0,a0 ; mv a2,b0 // 0 or 0xffff
	xor a0,b0,a0
$0:
	ldx (i6)-1,le;	ldy (i6),ls
	jr
	ldx (i6)-1,lc;	ldy (i6),b1


	.end
