⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpyp.s

📁 关于DVD上的PCM的解码的代码,PCM的DSP压缩,解调的算法,用RISC32指令来写.
💻 S
📖 第 1 页 / 共 3 页
字号:
	xor	r18, r19
	xor	r16, r18	
	andi	r16, 0x01	//r16=lower out
	shl	r12, 1		//l_lfsr<<1
	or	r12, r16
	xor	r16, r23	//b=lower out ^ LSW
	
	add	r5, r15, r16	//a+b
	add	r5, r13		//+diff. r5=s
	shr	r13, r5, 1	//diff=s>>1 (carry)
	andi	r5, 0x01	//s & 0x1 (add_out)
	shl	r21, 1		//curbyte<<1
	or	r21, r5	

inner_loop_0:
left_over_loop:
	
//	movb	LBipbyte4, r21
	mov	a3(-1*4), r21	;higher ip
	
//--- byte3=r20(31:24), byte2=r20(23:16), byte1=r20(15:8), byte0=r20(7:0)--

	shr	r6, r25, 2	//number of full words

	loop	r6, full_word_loop
	
	movi	r20, 0		//init curbyte

	loop	4, scheduler_loop
		
	loop	8, inner_loop_1
	
	shr	r15, r10, 16	//upper part
	shr	r16, r10, 2
	xor	r15, r16
	andi	r15, 0x01	//r15=upper out	
	shl	r10, 1		//u_lfsr<<1
	or	r10, r15
	xor	r15, r22	//a=upper out ^ USW
	
	shr	r16, r12, 24	//lower part
	shr	r17, r12, 21
	shr	r18, r12, 20
	shr	r19, r12, 12
	xor	r16, r17
	xor	r18, r19
	xor	r16, r18	
	andi	r16, 0x01	//r16=lower out
	shl	r12, 1		//l_lfsr<<1
	or	r12, r16
	xor	r16, r23	//b=lower out ^ LSW
	
	add	r5, r15, r16	//a+b
	add	r5, r13		//+diff. r5=s
	shr	r13, r5, 1	//diff=s>>1 (carry)
	andi	r5, 0x01	//s & 0x1 (add_out)
	shl	r20, 1		//curbyte<<1
	or	r20, r5	

inner_loop_1:
scheduler_loop:
	
//	movw	LBipbyte0, r20	
	mov	a3(-1*4), r20	; lower ip
full_word_loop:	
	
	j	r28	
	
	
	
	
	.text

;************************************************************************
; (c)1996-1997 Copyright M-Pact, Inc. All rights reserved
;
; Revision 1.0
;
;	
;
;	Module: SUB_Auth_Substitutor
;
;	Initial version:Jinshi Huang 4/14/97
;
;	Calling	:     	SUB_Auth_SBox, SUB_T_box
;	Called by:	Dec_Auth
;	Return:		r28, AGRAdr0
;	Param in:     	AGRAdr0
;	Temp reg:	
;	AGR  reg:	
;	Local buffer:
;************************************************************************

SUB_Auth_Substitutor:
//input: LBpcd;LBiak_byte; r22(LBpacc_byte)
//output: AGRAdr4 (LBrd)

	movi	AGRSiz4, 0xffff		; linear

//---------------- read in tables----------------------------

	movi	BlockSkip, 0
	movi	BlockSize, 31		
	movi	DMASize, 31		;read 32 words

	movi	r1,  LBPre_Tab_word	 
	movi	r15, Pre_Tab
	shr	r15, 2			;to word addr 

	loop	2, read_Pre_Tab		;total = 64 words = 256 bytes
	
	mov	LocalAddr,  r1
	dmarr	r15		
	WaitDma
	
	addi	r15, 32
	addi	r1, 32
read_Pre_Tab:

	movi	r1,  LBPost_Tab_word	 
	movi	r15, Post_Tab
	shr	r15, 2			;to word addr 

	loop	2, read_Post_Tab		;total = 64 words = 256 bytes
	
	mov	LocalAddr,  r1
	dmarr	r15		
	WaitDma

	addi	r15, 32
	addi	r1, 32
read_Post_Tab:	

	movi	r1,  LBAInv_Tab_word	 
	movi	r15, BAInv_Tab
	shr	r15, 2			;to word addr 

	loop	2, read_Inv_Tab		;total = 64 words = 256 bytes
	
	mov	LocalAddr,  r1
	dmarr	r15		
	WaitDma
	
	addi	r15, 32
	addi	r1, 32
read_Inv_Tab:

	movi	BlockSize, 7		
	movi	DMASize, 7		;read 8 words


	movi	r1,  LBAcc_Tab_word	 
	movi	r15, Acc_Tab
	shr	r15, 2			;to word addr 

	mov	LocalAddr,  r1
	dmarr	r15		
	WaitDma
	
	addi	r15, 32
	addi	r1, 32

	
//---------------------------------------------------------------

	movi	AGRAdr0, LBtmp_1_byte
	movb	r0, LBpcdbyte0		//convert bytes into "words of byte"
	mov	a0(1*4), r0		;p[0]
	movb	r0, LBpcdbyte1
	mov	a0(1*4), r0		;p[1]
	movb	r0, LBpcdbyte2
	mov	a0(1*4), r0		;p[2]
	movb	r0, LBpcdbyte3
	mov	a0(1*4), r0		;p[3]
	movb	r0, LBpcdbyte4
	mov	a0(0), r0		;p[4]
		
//------------------------ first round ----------------------------

	movi	AGRAdr1, LBtmp_byte+4*4	;output
	movi	AGRAdr2, LBtmp_1_byte+4*4
	
	movi	r21, LBiak_byte+29	;iak[29]

	jsr	r29, SUB_Auth_SBox	;out: tmp[4]
	
	mov	r0, a1(-1*4)		;dec output pointer

	loop	4, first_round_loop	;out: tmp[3]-[0]
	subi	r21, 1			;iak[28]-[25]

	jsr	r29, SUB_Auth_SBox
	
	mov	r0, a1(0)
	mov	r1, a2(-1*4)		;p[4]
	xor	a1(-1*4), r0, r1	;dec output pointer	
first_round_loop:

//------------------------ second round ----------------------------

	movi	AGRAdr1, LBtmp_1_byte+4*4	;output
	movi	AGRAdr0, LBtmp_byte+4*4	
	movi	AGRAdr2, LBtmp_byte+4*4
	movi	AGRAdr3, LBtmp_byte	
	
	movi	r21, LBiak_byte+24	;iak[24]
	mov	r0, a3(0)		;tmp[0]
	mov	r1, a2(0)		;tmp[4]
	xor	a2(0), r0, r1		;tmp[0] ^ tmp[4]


	jsr	r29,  SUB_Auth_SBox	;out: tmp_1[4]
	
	mov	r0, a1(-1*4)		;dec output pointer

	loop	4, second_round_loop	;out: tmp_1[3]-[0]

	subi	r21, 1			;iak[28]-[25]

	jsr	r29, SUB_Auth_SBox
	
	mov	r0, a1(0)
	mov	r1, a2(-1*4)		;p[4]
	xor	a1(-1*4), r0, r1	;dec output pointer	
second_round_loop:

//------------------------ third round ----------------------------

	movi	AGRAdr1, LBtmp_byte+4*4	;output
	movi	AGRAdr0, LBtmp_1_byte+4*4	
	movi	AGRAdr2, LBtmp_1_byte+4*4
	movi	AGRAdr3, LBtmp_1_byte	
	
	movi	r21, LBiak_byte+19	;iak[19]
	mov	r0, a3(0)		;tmp_1[0]
	mov	r1, a2(0)		;tmp_1[4]
	xor	a2(0), r0, r1		;tmp_1[0] ^ tmp_1[4]


	jsr	r29,  SUB_Auth_SBox	;out: tmp[4]
	

	jsr	r29, SUB_T_Box		;out: tmp[4]


	loop	4, third_round_loop	;out: tmp[3]-[0]

	subi	r21, 1			;iak[28]-[25]

	jsr	r29, SUB_Auth_SBox
	
	mov	r0, a1(0)
	mov	r1, a2(-1*4)		;p[4]
	xor	a1(0), r0, r1		;do NOT dec output pointer	

	jsr	r29, SUB_T_Box		;out: tmp[3]-[0]
	
	nop			; last inst in loop
third_round_loop:

//------------------------ fourth round ----------------------------

	movi	AGRAdr1, LBtmp_1_byte+4*4	;output
	movi	AGRAdr0, LBtmp_byte+4*4	
	movi	AGRAdr2, LBtmp_byte+4*4
	movi	AGRAdr3, LBtmp_byte	
	
	movi	r21, LBiak_byte+14	;iak[14]
	mov	r0, a3(0)		;tmp[0]
	mov	r1, a2(0)		;tmp[4]
	xor	a2(0), r0, r1		;tmp[0] ^ tmp[4]

	jsr	r29, SUB_Auth_SBox	;out: tmp_1[4]
	
	jsr	r29, SUB_T_Box		;out: tmp_1[4]


	loop	4, fourth_round_loop	;out: tmp_1[3]-[0]

	subi	r21, 1			;iak[28]-[25]

	jsr	r29, SUB_Auth_SBox
	
	mov	r0, a1(0)
	mov	r1, a2(-1*4)		;p[4]
	xor	a1(0), r0, r1		;do NOT dec output pointer	

	jsr	r29, SUB_T_Box		;out: tmp_1[3]-[0]
	
	nop			; last inst in loop
fourth_round_loop:

//------------------------ fifth round ----------------------------

	movi	AGRAdr1, LBtmp_byte+4*4	;output
	movi	AGRAdr0, LBtmp_1_byte+4*4	
	movi	AGRAdr2, LBtmp_1_byte+4*4
	movi	AGRAdr3, LBtmp_1_byte	
	
	movi	r21, LBiak_byte+9	;iak[9]
	mov	r0, a3(0)		;tmp_1[0]
	mov	r1, a2(0)		;tmp_1[4]
	xor	a2(0), r0, r1		;tmp_1[0] ^ tmp_1[4]

	jsr	r29, SUB_Auth_SBox	;out: tmp[4]
	
	mov	r0, a1(-1*4)		;dec output pointer

	loop	4, fifth_round_loop	;out: tmp[3]-[0]

	subi	r21, 1			;iak[28]-[25]

	jsr	r29, SUB_Auth_SBox
	
	mov	r0, a1(0)
	mov	r1, a2(-1*4)		;p[4]
	xor	a1(-1*4), r0, r1	;dec output pointer	
fifth_round_loop:
				
//------------------------ sixth round ----------------------------

	movi	AGRAdr1, LBtmp_1_byte+4*4	;output
	movi	AGRAdr0, LBtmp_byte+4*4	
	movi	AGRAdr2, LBtmp_byte+4*4
	movi	AGRAdr3, LBtmp_byte	
	
	movi	r21, LBiak_byte+4	;iak[4]
	mov	r0, a3(0)		;tmp[0]
	mov	r1, a2(0)		;tmp[4]
	xor	a2(0), r0, r1		;tmp[0] ^ tmp[4]

	jsr	r29, SUB_Auth_SBox	;out: tmp_1[4]
	
	mov	r11, a1(-1*4)		;dec output pointer. r11=RD(39:32)

	movi	r12, 0			;init
	
	loop	4, sixth_round_loop	;out: tmp_1[3]-[0]

	subi	r21, 1			;iak[3]-[0]

	jsr	r29, SUB_Auth_SBox
	
	mov	r0, a1(-1*4)		;dec output pointer	
	xor	r0, a2(-1*4)		;p[4]
	shl	r12, 8
	or	r12, r0	

sixth_round_loop:
				
//	movw	LRD_hi, r11
//	movw	LRD_lo, r12
	mov	a4(1*4), r12
	mov	a4(0), r11
	
	j	r28
						
	
;************************************************************************
; (c)1996-1997 Copyright M-Pact, Inc. All rights reserved
;
; Revision 1.0
;
;	
;
;	Module: SUB_Auth_SBox
;
;	Initial version:Jinshi Huang 4/14/97
;
;	Calling	:     	none
;	Called by:	Auth_Substitutor
;	Return:		r29, AGRAdr1
;	Param in:     	AGRAdr0, r21 (iak), pacc
;	Temp reg:	
;	AGR  reg:	
;	Local buffer:
;************************************************************************

SUB_Auth_SBox:		//(BYTE iak,BYTE p,BYTE pacc)
//input: AGRAdr0=>p(one byte each); r21=>iak; LBpacc_byte
//output: AGRAdr1 (one byte each)
	
	movb	r2, l21		;iak
	addi	r2, LBAInv_Tab_byte
	mov	r1, a0(-1*4)	;p
	movb	r0, l2
	xor	r3, r0, r1	;p ^ Inv_Tab[iak]
//	movb	r4, LBpaccbyte0	; use r22 now
	addi	r3, LBPre_Tab_byte
	addi	r4, r22, LBAcc_Tab_byte
	movb	r0, l3		;r0=Pre_Tab[tmp]
	movb	r1, l4		;r1=Acc_Tab[pacc]
	xor	r5, r0, r1	; ^
	addi	r5, LBPost_Tab_byte
	nop
	movb	r0, l5
	mov	a1(0), r0
	j 	r29
	
	
;************************************************************************
; (c)1996-1997 Copyright M-Pact, Inc. All rights reserved
;
; Revision 1.0
;
;	
;
;	Module: SUB_T_box
;
;	Initial version:Jinshi Huang 4/14/97
;
;	Calling	:     	none
;	Called by:	Auth_Substitutor
;	Return:		r29, AGRAdr0
;	Param in:     	AGRAdr1
;	Temp reg:	
;	AGR  reg:	
;	Local buffer:
;************************************************************************

SUB_T_Box:
	
	mov	r0, a1(0)
	shr	r1, r0, 1		;p>>1
	shl	r2, r0, 7
	or	r1, r2			;Rotate right by 1 bit
	andi	r1, 0x00ff
	xor	a1(-1*4), r0, r1	;dec out pointer
	j	r29
	


//------------------------------------------------------------------------
	.data
	
Pre_Tab:	.align	2
	.byte	0xc4
	.byte	0xcd
	.byte	0xce
	.byte	0xcb
	.byte	0xc8
	.byte	0xc9
	.byte	0xca
	.byte	0xcf
// 0
	.byte	0xcc
	.byte	0xc5
	.byte	0xc6
	.byte	0xc3
	.byte	0xc0
	.byte	0xc1
	.byte	0xc2
	.byte	0xc7

	.byte	0x14
	.byte	0x1d
	.byte	0x1e
	.byte	0x1b
	.byte	0x18
	.byte	0x19
	.byte	0x1a
	.byte	0x1f
// 10
	.byte	0x1c
	.byte	0x15
	.byte	0x16
	.byte	0x13
	.byte	0x10
	.byte	0x11
	.byte	0x12
	.byte	0x17

	.byte	0x24
	.byte	0x2d
	.byte	0x2e
	.byte	0x2b
	.byte	0x28
	.byte	0x29
	.byte	0x2a
	.byte	0x2f
// 20
	.byte	0x2c
	.byte	0x25
	.byte	0x26
	.byte	0x23
	.byte	0x20
	.byte	0x21
	.byte	0x22
	.byte	0x27

	.byte	0x34
	.byte	0x3d
	.byte	0x3e
	.byte	0x3b
	.byte	0x38
	.byte	0x39
	.byte	0x3a
	.byte	0x3f
// 30
	.byte	0x3c
	.byte	0x35
	.byte	0x36
	.byte	0x33
	.byte	0x30
	.byte	0x31
	.byte	0x32
	.byte	0x37

	.byte	0x04
	.byte	0x0d
	.byte	0x0e
	.byte	0x0b
	.byte	0x08
	.byte	0x09
	.byte	0x0a
	.byte	0x0f
// 40
	.byte	0x0c
	.byte	0x05
	.byte	0x06
	.byte	0x03
	.byte	0x00
	.byte	0x01
	.byte	0x02
	.byte	0x07

	.byte	0xd4
	.byte	0xdd
	.byte	0xde
	.byte	0xdb
	.byte	0xd8
	.byte	0xd9
	.byte	0xda
	.byte	0xdf
// 50
	.byte	0xdc
	.byte	0xd5
	.byte	0xd6
	.byte	0xd3
	.byte	0xd0
	.byte	0xd1
	.byte	0xd2
	.byte	0xd7

	.byte	0xe4
	.byte	0xed
	.byte	0xee
	.byte	0xeb
	.byte	0xe8
	.byte	0xe9
	.byte	0xea
	.byte	0xef
// 60
	.byte	0xec
	.byte	0xe5
	.byte	0xe6
	.byte	0xe3
	.byte	0xe0
	.byte	0xe1
	.byte	0xe2
	.byte	0xe7

	.byte	0xf4
	.byte	0xfd
	.byte	0xfe
	.byte	0xfb
	.byte	0xf8
	.byte	0xf9
	.byte	0xfa
	.byte	0xff
// 70
	.byte	0xfc
	.byte	0xf5
	.byte	0xf6
	.byte	0xf3
	.byte	0xf0
	.byte	0xf1
	.byte	0xf2
	.byte	0xf7

	.byte	0x44
	.byte	0x4d
	.byte	0x4e
	.byte	0x4b
	.byte	0x48
	.byte	0x49
	.byte	0x4a
	.byte	0x4f
// 80
	.byte	0x4c
	.byte	0x45
	.byte	0x46
	.byte	0x43
	.byte	0x40
	.byte	0x41
	.byte	0x42
	.byte	0x47

	.byte	0x94
	.byte	0x9d
	.byte	0x9e
	.byte	0x9b
	.byte	0x98
	.byte	0x99
	.byte	0x9a
	.byte	0x9f
// 90
	.byte	0x9c
	.byte	0x95
	.byte	0x96
	.byte	0x93
	.byte	0x90
	.byte	0x91
	.byte	0x92
	.byte	0x97

	.byte	0xa4
	.byte	0xad
	.byte	0xae
	.byte	0xab
	.byte	0xa8
	.byte	0xa9
	.byte	0xaa
	.byte	0xaf
// a0
	.byte	0xac
	.byte	0xa5
	.byte	0xa6
	.byte	0xa3
	.byte	0xa0
	.byte	0xa1
	.byte	0xa2
	.byte	0xa7

	.byte	0xb4
	.byte	0xbd
	.byte	0xbe
	.byte	0xbb
	.byte	0xb8
	.byte	0xb9
	.byte	0xba
	.byte	0xbf
// b0
	.byte	0xbc
	.byte	0xb5
	.byte	0xb6
	.byte	0xb3
	.byte	0xb0
	.byte	0xb1
	.byte	0xb2
	.byte	0xb7

	.byte	0x84
	.byte	0x8d
	.byte	0x8e
	.byte	0x8b
	.byte	0x88
	.byte	0x89
	.byte	0x8a
	.byte	0x8f
// c0
	.byte	0x8c
	.byte	0x85
	.byte	0x86
	.byte	0x83
	.byte	0x80
	.byte	0x81
	.byte	0x82
	.byte	0x87

	.byte	0x54
	.byte	0x5d
	.byte	0x5e
	.byte	0x5b
	.byte	0x58
	.byte	0x59
	.byte	0x5a
	.byte	0x5f
// d0
	.byte	0x5c
	.byte	0x55
	.byte	0x56
	.byte	0x53
	.byte	0x50
	.byte	0x51
	.byte	0x52
	.byte	0x57

	.byte	0x64
	.byte	0x6d
	.byte	0x6e
	.byte	0x6b
	.byte	0x68
	.byte	0x69
	.byte	0x6a
	.byte	0x6f
// e0
	.byte	0x6c
	.byte	0x65
	.byte	0x66
	.byte	0x63
	.byte	0x60
	.byte	0x61
	.byte	0x62
	.byte	0x67

	.byte	0x74
	.byte	0x7d
	.byte	0x7e
	.byte	0x7b
	.byte	0x78
	.byte	0x79
	.byte	0x7a
	.byte	0x7f
// f0
	.byte	0x7c
	.byte	0x75
	.byte	0x76
	.byte	0x73
	.byte	0x70
	.byte	0x71
	.byte	0x72
	.byte	0x77


Post_Tab:	.align	2
	.byte	0xc4
	.byte	0x24
	.byte	0x14
	.byte	0x34
	.byte	0xce
	.byte	0x2e
	.byte	0x1e
	.byte	0x3e

	.byte	0xcd
	.byte	0x2d
	.byte	0x1d
	.byte	0x3d
	.byte	0xcb
	.byte	0x2b
	.byte	0x1b
	.byte	0x3b

	.byte	0x44
	.byte	0xa4
	.byte	0x94
	.byte	0xb4
	.byte	0x4e
	.byte	0xae
	.byte	0x9e
	.byte	0xbe
// 10
	.byte	0x4d
	.byte	0xad
	.byte	0x9d
	.byte	0xbd
	.byte	0x4b
	.byte	0xab
	.byte	0x9b
	.byte	0xbb

	.byte	0x04
	.byte	0xe4
	.byte	0xd4
	.byte	0xf4
	.byte	0x0e
	.byte	0xee
	.byte	0xde
	.byte	0xfe
// 20
	.byte	0x0d
	.byte	0xed
	.byte	0xdd
	.byte	0xfd
	.byte	0x0b
	.byte	0xeb
	.byte	0xdb
	.byte	0xfb

	.byte	0x84
	.byte	0x64
	.byte	0x54
	.byte	0x74
	.byte	0x8e
	.byte	0x6e
	.byte	0x5e
	.byte	0x7e
// 30
	.byte	0x8d

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -