
;  GNU C 2.7.2 [AL 1.1, MM 40] RISC NEWS-OS compiled by CC

;  Cc1 defaults:
;  -mmemcpy

;  Cc1 arguments (-G value = 0, Cpu = 3000, ISA = 1):
;  -quiet -dumpbase -O2 -Wall -o

gcc2_compiled.:
__gnu_compiled_c:
; APP
	
	.code
	.global ldirect_mkbuf
ldirect_mkbuf:
	ext	0x16		; 	xld.w %r15, 1408		; %r15 = DISP_X / 8 * DISP_Y
	ld.w	%r15,0x0
ldirect_mkbuf_LOOP:
	ld.w %r10, [%r13]+		; %r10 = pixel0to3
	ld.w %r11, [%r13]+		; %r11 = pixel4to7
	sll	%r10,0x4	; 	xsll %r10, 4			; %r10 = pixel0to3 << 4 | pixel4to7
	or %r10, %r11
	ld.w [%r12]+, %r10		; store (pixel0to3 << 4 | pixel4to7)
	sub	%r15,0x1	; 	xsub %r15, %r15, 1
	jrne	ldirect_mkbuf_LOOP	; 	xjrne ldirect_mkbuf_LOOP
	ret

	
	.code
	.global ldirect_trans
ldirect_trans:
	ext	0x0		; 	xld.w %r4, 0x401f5		; %r4 = pSIF3_TXD
	ext	0x1007
	ld.w	%r4,0x35
	ext	0x0		; 	xld.w %r5, 0x401f7		; %r5 = pSIF3_STATUS
	ext	0x1007
	ld.w	%r5,0x37
	ext	0x0		; 	xld.w %r6, 0x402d9		; %r6 = pP2_P2D
	ext	0x100b
	ld.w	%r6,0x19
	;
	ld.w	%r14,0x9	; 	xld.w %r14, 9			; %r14 = page = { 9,8,7,6,5,4,3,2,1,0,15,14,13,12,10 }
ldirect_trans_LOOP_X:
	;
	;	コマンド送信
	;
	bclr [%r6], 1			; bP2_P2D_P21D = 0
	;
	mirror %r10, %r14		; %r10 = mirror(0xb0 | page)
	or	%r10,0xd	; 	xoor %r10, %r10, 0x0d		;      = 0x0d | mirror(page)
ldirect_trans_L10:
	btst [%r5], 1			; while(!bSIF3_STATUS_TDBE3) { }
	jreq	ldirect_trans_L10	; 	xjreq ldirect_trans_L10
	ld.b [%r4], %r10		; pSIF3_TXD = %r10
	;
	ld.w	%r10,0x8	; 	xld.w %r10, 0x08		; %r10 = mirror(0x10) = 0x08
ldirect_trans_L20:
	btst [%r5], 1			; while(!bSIF3_STATUS_TDBE3) { }
	jreq	ldirect_trans_L20	; 	xjreq ldirect_trans_L20
	ld.b [%r4], %r10		; pSIF3_TXD = %r10
	;
	ld.w	%r10,0x0	; 	xld.w %r10, 0x00		; %r10 = mirror(0x00) = 0x00
ldirect_trans_L30:
	btst [%r5], 1			; while(!bSIF3_STATUS_TDBE3) { }
	jreq	ldirect_trans_L30	; 	xjreq ldirect_trans_L30
	ld.b [%r4], %r10		; pSIF3_TXD = %r10
	;
ldirect_trans_L40:
	btst [%r5], 5			; while(bSIF3_STATUS_TEND3) { }
	jrne	ldirect_trans_L40	; 	xjrne ldirect_trans_L40
	;
	;	データ送信
	;
	bset [%r6], 1			; bP2_P2D_P21D = 1
	;
	ext	0x1		; 	xld.w %r15, 88			; %r15 = DISP_Y
	ld.w	%r15,0x18
ldirect_trans_LOOP_Y:
	;
	; ※以下の命令列、インターロック回避しようとしてレジスタ割り当ての変更や命令の並び替えを行うと、
	;   なぜか余計に遅くなります。文書化されていない、外部メモリアクセスパターンの特性でしょうか？
	;   とりあえずこのままで・・・
	;
	ld.ub %r11, [%r12]+		; [4],[0]
	sll	%r11,0x1	; 	xsll %r11, 1			; !INTERLOCK!
	add %r11, %r13
	ld.uh %r10, [%r11]
	;
	ld.ub %r11, [%r12]+		; [5],[1]
	sll	%r11,0x1	; 	xsll %r11, 1			; !INTERLOCK!
	add %r11, %r13
	ld.uh %r11, [%r11]
	srl	%r10,0x1	; 	xsrl %r10, 1			; *anti-interlock*
	or %r10, %r11
	;
	ld.ub %r11, [%r12]+		; [6],[2]
	sll	%r11,0x1	; 	xsll %r11, 1			; !INTERLOCK!
	add %r11, %r13
	ld.uh %r11, [%r11]
	srl	%r10,0x1	; 	xsrl %r10, 1			; *anti-interlock*
	or %r10, %r11
	;
	ld.ub %r11, [%r12]		; [7],[3]
	sll	%r11,0x1	; 	xsll %r11, 1			; !INTERLOCK!
	add %r11, %r13
	ld.uh %r11, [%r11]
	srl	%r10,0x1	; 	xsrl %r10, 1			; *anti-interlock*
	or %r10, %r11
	;
ldirect_trans_L50:
	btst [%r5], 1			; while(!bSIF3_STATUS_TDBE3) { }
	jreq	ldirect_trans_L50	; 	xjreq ldirect_trans_L50
	ld.b [%r4], %r10		; pSIF3_TXD = %r10
	;
	add	%r12,0x3d	; 	xadd %r12, %r12, 61		; %r12 += (DISP_X / 2) - (8 / 2 - 1)
	srl	%r10,0x8	; 	xsrl %r10, 8			; %r10 >>= 8
	;
ldirect_trans_L60:
	btst [%r5], 1			; while(!bSIF3_STATUS_TDBE3) { }
	jreq	ldirect_trans_L60	; 	xjreq ldirect_trans_L60
	ld.b [%r4], %r10		; pSIF3_TXD = %r10
	;
	sub	%r15,0x1	; 	xsub %r15, %r15, 1
	jrne	ldirect_trans_LOOP_Y	; 	xjrne ldirect_trans_LOOP_Y
	;
	ext	0x57		; 	xsub %r12, %r12, 5628		; wbuff += (8 / 2) - (DISP_X / 2 * DISP_Y)
	sub	%r12,0x3c
	sub	%r14,0x1	; 	xsub %r14, %r14, 1		; page = (page - 1) & 15
	and	%r14,0xf	; 	xand %r14, %r14, 15
	;
ldirect_trans_L70:
	btst [%r5], 5			; while(bSIF3_STATUS_TEND3) { }
	jrne	ldirect_trans_L70	; 	xjrne ldirect_trans_L70
	;
	cmp	%r14,0x9	; 	xcmp %r14, 9
	jrne	ldirect_trans_LOOP_X	; 	xjrne ldirect_trans_LOOP_X
	;
	ret

