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

📄 bitcodes.s

📁 arm ads1.2 with crack.rar
💻 S
📖 第 1 页 / 共 2 页
字号:
	; end bit coding process
	;
	; save the last coded data, save the last bit stream and position
	; reached in the stream to the structure, restore registers and return
	;
	; $bits				register: number of bits free in $dstword
	; $dstword			register: current coded word
	; $deststream		register: bit stream to write $dstword
	; $finaldeststreamaddress
	;					register: to hold final stream structure returned
	; $t				register: temporary
	;
	; $bits, $dstword, $deststream and $t must all be distinct
	;
	;---------------------------------------------------------------
	MACRO
	ENDBITCODING $bits, $dstword, $deststream, $finaldeststreamaddress, $t
	    ; check that registers are distinct
	    DISTINCT $bits, $dstword, $deststream, $t

		IF {ENDIAN} = "little"				; the bit operations are big endian but if the coding is performed in little endian mode
			BYTEREV $dstword, $dstword, $t	; then the byte of a word need reversing to make them little endian before they can be saved
		ENDIF

		STR		$dstword, [ $deststream ]	; store last destination stream word that has not previously been saved
		CMP		$bits, #0					; check if destination word is completely full
		ADDEQ	$deststream, $deststream, #4	; if destination word is full, increment destination pointer to next
												; position so next data will be added to end of data already coded
											; if the stream word was not full, the pointer is not incremented so that if the coder is
											; called again coding will continue into the last bit position that was reached thus the 
											; incomplete word that has just been saved will need to be read back in again
		
		LDMFD	sp!, { $t }					; read the state structure parameter from the stack that was saved at initialisation
											; the structure is read into $t since $finaldeststreamaddress could easily be one of
											; $deststream or $bits which are still required
		STMIA	$t, { $deststream, $bits }	; store the new bit stream pointer and number of bits free in next word referenced by stream
		MOV		$finaldeststreamaddress, $t	; set up the return register with the returned structure
		
		RETURN	"R8 - R12","","",""			; coding complete, restore registers and return (rlist, sp, lr, no condition)
	MEND
	
; --------------------
;
; function entry point
;
; --------------------
	
	;---------------------------------------------------------------
	; general bit coding
	;
	; call the appropriate bit coding function for given size of data
	;
	; source		register: the source data to code as bytes,
	;							halfwords or words
	; n				register: the number of data items to code
	; streamstr		register: pointer to a structure that must contain
	;				an unsigned character array as first entry that is
	; 				the bitstream to use and an
	;				unsigned integer as second entry that is the
	;				bit position in this array to start from
	; codes			register: symbol-to-codeword table
	; datatype		stacked 8, 16 or 32 as size of symbol data
	;
	;---------------------------------------------------------------
	IF GENBITCODE = 1
		; define the general bit coding function as necessary which requires all other bit coding functions to be defined
		EXPORT	BitCodeSymbols

BitCodeSymbols
		LDMFD	sp, { R12 }					; get "datatype" variable from stack, leaving stack pointer referencing it

		CMP		R12, #8						; if "datatype" is 8 then the data is bytes
		BEQ		BitCodeByteSymbols

		CMP		R12, #16					; if "datatype" is 16 then the data is halfwords
		BEQ		BitCodeHalfWordSymbols
		
		CMP		R12, #32					; if "datatype" is 32 then the data is words
											; this check is made to ensure that no other size can be given
		BEQ		BitCodeWordSymbols
		
		; if this point is reached the value of "datatype" was incorrect so just return
		MOV		fin_stream, streamstr		; expected return is the state structure so move this into the return register
		RETURN	"","","",""					; return (no rlist, sp, lr, no condition)
	ENDIF

	;---------------------------------------------------------------
	; byte bit coding
	;
	; bit code byte symbols to variable length codewords
	;
	; source		register: the source data to code as bytes
	; n				register: the number of bytes to code
	; streamstr		register: pointer to a structure that must contain
	;				an unsigned character array as first entry that is
	; 				the bitstream to use and an
	;				unsigned integer as second entry that is the
	;				bit position in this array to start from
	; codes			register: symbol-to-codeword table
	;
	;---------------------------------------------------------------
	IF GENBITCODE = 1 :LOR: BYTEBITCODE = 1
		; define the byte coding function as necessary
		EXPORT	BitCodeByteSymbols

BitCodeByteSymbols
		; initialise the bit coder - save registers and set up first stream word
		INITIALISEBITCODING streamstr, deststream, bits, dstword, t
		
		; process the source data as bytes calling the bit coding for each source byte
		PROCESSBYTES n, source, srcword, byte, t, "BITCODE codes, byte, codeword, bits, dstword, deststream, t, 32"
		
		; end the bit coder - ensure all data is saved, restore the registers and return
		ENDBITCODING bits, dstword, deststream, fin_stream, t
	ENDIF

	;---------------------------------------------------------------
	; halfword bit coding
	;
	; bit code halfword symbols to variable length codewords
	;
	; source		register: the source data to code as halfwords
	; n				register: the number of halfwords to code
	; streamstr		register: pointer to a structure that must contain
	;				an unsigned character array as first entry that is
	; 				the bitstream to use and an
	;				unsigned integer as second entry that is the
	;				bit position in this array to start from
	; codes			register: symbol-to-codeword table
	;
	;---------------------------------------------------------------
	IF GENBITCODE = 1 :LOR: HWORDBITCODE = 1
		; define the halfword coding function as necessary
		EXPORT	BitCodeHalfWordSymbols

BitCodeHalfWordSymbols
		; initialise the bit coder - save registers and set up first stream word
		INITIALISEBITCODING streamstr, deststream, bits, dstword, t
		
		; process the source data as halfwords calling the bit coding for each source halfword
		PROCESSHWORDS n, source, srcword, hword, "BITCODE codes, hword, codeword, bits, dstword, deststream, t, 32"
		
		; end the bit coder - ensure all data is saved, restore the registers and return
		ENDBITCODING bits, dstword, deststream, fin_stream, t
	ENDIF

	;---------------------------------------------------------------
	; word bit coding
	;
	; bit code word symbols to variable length codewords
	;
	; source		register: the source data to code as words
	; n				register: the number of words to code
	; streamstr		register: pointer to a structure that must contain
	;				an unsigned character array as first entry that is
	; 				the bitstream to use and an
	;				unsigned integer as second entry that is the
	;				bit position in this array to start from
	; codes			register: symbol-to-codeword table
	;
	;---------------------------------------------------------------
	IF GENBITCODE = 1 :LOR: WORDBITCODE = 1
		; define the word coding function as necessary
		EXPORT	BitCodeWordSymbols

BitCodeWordSymbols
		; initialise the bit coder - save registers and set up first stream word
		INITIALISEBITCODING streamstr, deststream, bits, dstword, t
		
		; process the source data as words calling the bit coding for each source word
		PROCESSWORDS n, source, srcword, "BITCODE codes, srcword, codeword, bits, dstword, deststream, t, 32"
		
		; end the bit coder - ensure all data is saved, restore the registers and return
		ENDBITCODING bits, dstword, deststream, fin_stream, t
	ENDIF


	END

⌨️ 快捷键说明

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