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

📄 condec.inc

📁 代码保护功能处于持续发展中。Microchip 承诺将不断改进产品的代码保护功能。任何试图破坏Microchip 代码保护功能的行为均可视 为违反了《数字器件千年版权法案(Digital Mille
💻 INC
字号:
;
;-----------------------------------------------------------
; CONDEC.INC	MPB		1-7-05
; Converts 8-bit binary to decimal
; Returns digits in Huns, Tens, Ones registers
;-----------------------------------------------------------

ADbin	EQU	77	; Binary input value
Huns	EQU	78	; Hundreds digit in decimal value
Tens	EQU	79	; Tens digit in decimal value
Ones	EQU	7A	; Ones digit in decimal value

;-----------------------------------------------------------
; Convert input to decimal 

condec	MOVWF	ADbin		; get ADC result
	CLRF	Huns		; zero hundreds digit
	CLRF	Tens		; zero Tens digit
	CLRF	Ones		; zero Ones digit

; Calclulate hundreds.......................................

	BSF	STATUS,C	; set carry for subtract
	MOVLW	D'100'		; load 100
sub1	SUBWF	ADbin		; and subtract from result
	INCF	Huns		; count number of loops
	BTFSC	STATUS,C	; and check if done
	GOTO	sub1		; no, carry on

	ADDWF	ADbin		; yes, add 100 back on
	DECF	Huns		; and correct loop count

; Calculate Tens digit......................................

	BSF	STATUS,C	; repeat process for Tens
	MOVLW	D'10'		; load 10
sub2	SUBWF	ADbin		; and subtract from result
	INCF	Tens		; count number of loops
	BTFSC	STATUS,C	; and check if done
	GOTO	sub2		; no, carry on

	ADDWF	ADbin		; yes, add 100 back on
	DECF	Tens		; and correct loop count
	MOVF	ADbin,W		; load remainder
	MOVWF	Ones		; and store as Ones digit

	RETURN			; done

⌨️ 快捷键说明

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