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

📄 huffmanencode.asm

📁 这是一个数字图像处理的matlab仿真程序
💻 ASM
字号:
		.code
HuffmanEncode?	proc	uses ebx esi edi,$SymbolNumber,$lpHuffmanNode
		LOCAL	@ConstMaximum
		LOCAL	@MinIndex1,@MinIndex2
		LOCAL	@InitialEsp,@TempEsp

		mov	@InitialEsp,esp
		mov	eax,$SymbolNumber
		lea	ecx,[eax*4]
		sub	esp,ecx
		mov	ebx,esp
		mov	@ConstMaximum,-1

		mov	eax,$lpHuffmanNode
		mov	ecx,0
		.repeat
			assume	eax:ptr HUFFMANNODE
			mov	[eax].HuffmanCode,0
			mov	[eax].CodeLength,0
			mov	[eax].LeafNodeFlag,TRUE
			mov	[ebx][ecx*4],eax
			add	eax,sizeof HUFFMANNODE
			inc	ecx
			assume	eax:nothing
		.until	ecx ==	$SymbolNumber

		assume	esi:ptr HUFFMANNODE
		assume	edi:ptr HUFFMANNODE
		mov	edx,$SymbolNumber
		.repeat
			lea	esi,@ConstMaximum
			lea	edi,@ConstMaximum
			mov	@MinIndex1,0
			mov	@MinIndex2,1
			mov	ecx,0
			.while	ecx !=	edx
				mov	eax,[ebx][ecx*4]
				mov	eax,[eax]
				.if	eax <	[esi].Probability
					mov	edi,esi
					mov	esi,[ebx][ecx*4]
					m2m	@MinIndex2,@MinIndex1
					mov	@MinIndex1,ecx
				.elseif	eax <	[edi].Probability
					mov	edi,[ebx][ecx*4]
					mov	@MinIndex2,ecx
				.endif
				inc	ecx
			.endw
			push	FALSE
			push	edi
			push	esi
			mov	eax,[esi].Probability
			add	eax,[edi].Probability
			push	eax
			
			mov	eax,@MinIndex1
			m2m	[ebx][eax*4],esp
			mov	eax,@MinIndex2
			m2m	[ebx][eax*4],[ebx][edx*4-4]

			mov	@TempEsp,esp
			push	esi
			.while	esp !=	@TempEsp
				pop	esi
				.if	[esi].Probability != 0
					.if	[esi].LeafNodeFlag == TRUE
						inc	[esi].CodeLength
					.else
						push	[esi].LeftChild
						push	[esi].RightChild
					.endif
				.endif
			.endw
			push	edi
			.while	esp !=	@TempEsp
				pop	edi
				.if	[edi].Probability != 0
					.if	[edi].LeafNodeFlag == TRUE
						mov	eax,[edi].CodeLength
						bts	[edi].HuffmanCode,eax
						inc	[edi].CodeLength
					.else
						push	[edi].LeftChild
						push	[edi].RightChild
					.endif
				.endif
			.endw
			dec	edx
		.until	edx ==	1


		mov	esp,@InitialEsp
		assume	esi:nothing
		assume	edi:nothing
		ret
HuffmanEncode?	endp

⌨️ 快捷键说明

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