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

📄 simp.lst

📁 温度测量
💻 LST
📖 第 1 页 / 共 4 页
字号:
          .def	drem16uL=r14 	; Dump (Temp Only)
          .def	drem16uH=r15	; Dump (Temp Only)
         
          .def	dres16uL=r16	; Keep (valuel)
          .def	dres16uH=r17	; Keep (valueh)
          .def	dd16uL	=r16	; 00
          .def	dd16uH	=r17	; count_per_c - countremain
         
          .def	dv16uL	=r12	; count_per_c
          .def	dv16uH	=r13	; 00
         	
000143 2cc9      	mov	dv16uL, count_per_c
000144 24dd      	clr	dv16uH
000145 2700      	clr	dd16uL
         	
000146 24ee      div16u:	clr	drem16uL		;clear remainder Low byte
000147 18ff      	sub	drem16uH,drem16uH	;clear remainder High byte and carry
000148 e121      	ldi	count,17		;init loop counter
000149 1f00      d16u_1:	rol	dd16uL			;shift left dividend
00014a 1f11      	rol	dd16uH
00014b 952a      	dec	count			;decrement counter
00014c f409      	brne	d16u_2			;if done
00014d c00b      	rjmp	dump_3			;Finished here
         		
00014e 1cee      d16u_2:	rol	drem16uL		;shift dividend into remainder
00014f 1cff      	rol	drem16uH
000150 18ec      	sub	drem16uL,dv16uL		;remainder = remainder - divisor
000151 08fd      	sbc	drem16uH,dv16uH		;
000152 f420      	brcc	d16u_3			;if result negative
000153 0cec      	add	drem16uL,dv16uL		;    restore remainder
000154 1cfd      	adc	drem16uH,dv16uH
000155 9488      	clc				;    clear carry to be shifted into result
000156 cff2      	rjmp	d16u_1			;else
000157 9408      d16u_3:	sec				;    set carry to be shifted into result
000158 cff0      	rjmp	d16u_1
         	
          dump_3:
         	; We want Low & High result
         	; Result in R16 (valuel) (Always Positive)
         	; add R16 to vallow
         	; add R17 to valhigh
         	
000159 0f60      	add	vallow, valuel		; Add count remaining
00015a 1f71      	adc	valhigh, valueh		; Add 
         		
00015b 2f06      	mov	valuel, vallow
00015c 2ed7      	mov	temph, valhigh		;Store Temp High (Final Value)
         	
         	; Check if negative Number!!
         	
00015d fed7      	sbrs	temph, 7
00015e c006      	rjmp	ptemp			; Temp is positive
         	
         	; Invert fraction for conversion
00015f 9501      	neg	valuel
         	
         	; Quick Fix 21th Sept 2002
         	; Fixes jumps at whole negative temperatures
000160 e010      	ldi	r17, 00
000161 1701      	cp	valuel, r17
000162 f411      	brne	ptemp
000163 e011      	ldi	r17, 01
000164 1ad1      	sub	temph, r17
         	
         	; Fraction in valuel must convert to displayable number!
         	; Therefore multiply by 64h and dump LSB
         	
         	; valuel -> multiplicand
         	; valueh -> multiplier
         	; result -> Result High Byte
         	; valueh -> Result Low Byte -> Discard
         
          ptemp:
000165 e614      	ldi	valueh, 0x64		;Multiplier	
         	
000166 24ff      mpy8u:	clr	result			;clear result High byte
000167 e028      	ldi	count,8			;init loop counter
000168 9516      	lsr	valueh			;rotate multiplier
         	
000169 f408      m8u_1:	brcc	m8u_2			;carry set 
00016a 0ef0      	add 	result, valuel		;add multiplicand to result High byte
00016b 94f7      m8u_2:	ror	result			;rotate right result High byte
00016c 9517      	ror	valueh			;rotate right result L byte and multiplier
00016d 952a      	dec	count			;decrement loop counter
00016e f7d1      	brne	m8u_1			;if not done, loop more
         
00016f 2ccf      	mov	templ, result		;Store Temp Low
000170 9508      	ret
         	
         ;*** Working as of July 2002 !! Removed from sub1200 ***
         
         
         ;************************************************
         ;* Dump Temp from SRAM to LCD (real value)	*
         ;* High Resolution Version			*
         ;* 						*
         ;************************************************
         	
         	; Display Now
         	
          DS_disp:
         
         	; Check for positive number
000171 fed7      	sbrs	temph, 7
000172 f099      	breq	postemp2		; Temp is Positive!
         
         	; Display a negative number!!
         
000173 e21d      	ldi	data, '-'
000174 df1b      	rcall	onechar
         	
000175 ef9f      	ldi	hex, 0xff
000176 199d      	sub	hex, temph
         	;mov	hex, temph
         	;neg	hex
000177 d05e      	rcall	hexdec			;Convert to decimal
000178 e210      	ldi	data, ' '
         	
000179 2f17      	mov 	data, tens
00017a df15      	rcall	onechar
         	
00017b 2f16      	mov 	data, unit
00017c df13      	rcall	onechar
         	
00017d e21e      	ldi	data, '.'
00017e df11      	rcall	onechar
         	
00017f 2d9c      	mov	hex, templ
000180 d055      	rcall	hexdec
         	
000181 2f17      	mov 	data, tens		; Value can only be 0 - 99! No hundreds
000182 df0d      	rcall	onechar
         	
000183 2f16      	mov 	data, unit
000184 df0b      	rcall	onechar
         
000185 c012      	rjmp	ds_dec
         	
          postemp2:
         
000186 e210      	ldi	data, ' '
000187 df08      	rcall	onechar
         		
000188 2d9d      	mov	hex, temph		;Get High Value
000189 779f      	cbr	hex, 0x80
00018a d04b      	rcall	hexdec			;Convert to decimal
00018b e210      	ldi	data, ' '
         	
00018c 2f17      	mov 	data, tens
00018d df02      	rcall	onechar
         	
00018e 2f16      	mov 	data, unit
00018f df00      	rcall	onechar
         	
         	; decimal place
000190 e21e      	ldi	data, '.'
000191 defe      	rcall	onechar
         	
000192 2d9c      	mov	hex, templ
000193 d042      	rcall	hexdec
         	
000194 2f17      	mov 	data, tens		; Value can only be 0 - 99! No hundreds
000195 defa      	rcall	onechar
         	
000196 2f16      	mov 	data, unit
000197 def8      	rcall	onechar
         
          ds_dec:	
000198 e413      	ldi	data, 'C'
000199 def6      	rcall	onechar	
00019a 9508      	ret
         
         ;************************************************
         ;* Dump registers to LCD			*
         ;* High Resolution Version			*
         ;* 						*
         ;************************************************
         
          dump_reg:
         
00019b 2d92      	mov	hex, templsb		;Get High Value
00019c d01b      	rcall	hexasc			;Convert to Ascii
00019d e210      	ldi	data, ' '
         	
00019e 2f17      	mov 	data, tens
00019f def0      	rcall	onechar
         	
0001a0 2f16      	mov 	data, unit
0001a1 deee      	rcall	onechar
         	
0001a2 2d93      	mov	hex, tempmsb		;Get High Value
0001a3 d014      	rcall	hexasc			;Convert to Ascii
0001a4 e210      	ldi	data, ' '
         	
0001a5 2f17      	mov 	data, tens
0001a6 dee9      	rcall	onechar
         	
0001a7 2f16      	mov 	data, unit
0001a8 dee7      	rcall	onechar
         	
0001a9 2d98      	mov	hex, count_remain	;Get High Value
0001aa d00d      	rcall	hexasc			;Convert to Ascii
0001ab e210      	ldi	data, ' '
         	
0001ac 2f17      	mov 	data, tens
0001ad dee2      	rcall	onechar
         	
0001ae 2f16      	mov 	data, unit
0001af dee0      	rcall	onechar
         	
0001b0 2d99      	mov	hex, count_per_c	;Get High Value
0001b1 d006      	rcall	hexasc			;Convert to Ascii
0001b2 e210      	ldi	data, ' '
         	
0001b3 2f17      	mov 	data, tens
0001b4 dedb      	rcall	onechar
         	
0001b5 2f16      	mov 	data, unit
0001b6 ded9      	rcall	onechar
         		
0001b7 9508      	ret
         	          .include "convert.asm"
         ;************************************************
         ;* Conversion routines for AVR's		*
         ;*						*
         ;* Copyright 2001-2003 Wayne Peacock		*
         ;* First Revision 2nd July 2001			*
         ;************************************************
         ;* Disclaimer:					*
         ;* The Author takes no responsibility for the 	*
         ;* use of this code. Use at your own risk!	*
         ;* 						*
         ;* This code or part there of is licensed only 	*
         ;* for private use and NOT for commercial use.	*
         ;* 						*
         ;* Please contact the Author 'Wayne Peacock' 	*
         ;* <wpeacock@senet.com.au> before using the code*
         ;* or part there of in a commercial project.	*
         ;************************************************
         
         ; Requires the following 
          .def	unit	= r22
          .def	tens	= r23
          .def	hund	= r24		; Used as Temp in hexasc!
          .def	hex	= r25
          
         ;************************************************
         ;* Converts hex value to two ascii values	*
         ;* for LCD or RS232 etc....			*
         ;* Input: 	hex				*
         ;* Output:	unit				*
         ;*		tens				*	
         ;* Requires:	temp				*	
         ;************************************************        
         
         	; Convert first nibble  
          hexasc:	   
0001b8 2f69      	mov unit, hex		; Copy value to work with
0001b9 706f      	cbr unit, 0xF0		; Remove high nibble
         	
0001ba 306a      	cpi unit, 0x0A		; Check if 0-9
0001bb f410      	brsh hexasc1
         	
0001bc 6360      	sbr unit, 0x30		; Value must be 0-9	
0001bd c002      	rjmp hexasc2
         	
          hexasc1:	
0001be e387      	ldi hund, 0x37		; Value must be A-F
0001bf 0f68      	add unit,hund 
         
         	; Convert second nibble
          hexasc2:
0001c0 2f79      	mov tens, hex		; Copy value to work with
0001c1 9572      	swap tens		
0001c2 707f      	cbr tens, 0xF0		; Remove high nibble
         
0001c3 307a      	cpi tens, 0x0A		; Check if 0-9
0001c4 f410      	brsh hexasc3
         
0001c5 6370      	sbr tens, 0x30		; Value must be 0-9
0001c6 9508      	ret
         	
          hexasc3:	
0001c7 e387      	ldi hund, 0x37		; Value must be A-F
0001c8 0f78      	add tens,hund
0001c9 9508      	ret
         
         ;************************************************
         ;* Converts two ascii values to one hex		*
         ;* for user input (RS232 etc....)		*
         ;*						*
         ;* Input:	unit				*
         ;* 		tens (overwrites) 		*
         ;* Output: 	hex				*
         ;************************************************        
         
           	; Convert first ascii value
          aschex:
         	
0001ca 2f96      	mov hex, unit		; Move units into hex
0001cb 5390      	subi hex,0x30		; 
0001cc 309a      	cpi hex, 0x0a		; Check for A to F
0001cd f008          	brlo aschex1
0001ce 5097          	subi hex, 0x07		; Convert A-F to hex   	
         
             	; Convert second ascii value
          aschex1:
0001cf 5370      	subi tens, 0x30
0001d0 307a      	cpi tens, 0x0a		; Check if A to F
0001d1 f008      	brlo aschex2
0001d2 5077      	subi tens, 0x07		; Converts A-F to hex
         	
          aschex2:	
0001d3 9572      	swap tens
0001d4 0f97      	add hex, tens		; Add values together
0001d5 9508      	ret
         
         ;************************************************
         ;* Converts hex value to decimal (3 ASCII 	*
         ;* values) for user output (RS232, LCD etc....)	*
         ;*						*
         ;* Input:	hex				*
         ;* Output: 	unit				*
         ;*		tens				*
         ;*		hund				*
         ;************************************************        
          
          hexdec: 
0001d6 e360      	ldi unit,0x30	; Units 
0001d7 e370              ldi tens,0x30 	; Tens
0001d8 e380              ldi hund,0x30	; Hundreds
         
0001d9 3694      	cpi hex,0x64 	; Compare the quantity in Hex =>100(64 in Hex) 
0001da f420              brsh hexdec1	; Over 100!
                 
0001db 309a              cpi hex,0x0A 	; Compare if we have 10 inside the number 
0001dc f440              brsh hexdec2    ; Tens to convert
0001dd 0f69              add unit,hex	; Units only
0001de 9508              ret		
                  
          hexdec1:      	
0001df 5694      	subi hex,0x64 	; Get hundreds by subtracting 100 
0001e0 9583              inc hund    	   
0001e1 3694              cpi hex,0x64    ; Repeat until under 100
0001e2 f7e0              brsh hexdec1 
                  
0001e3 309a              cpi hex,0x0A  	; Check if the result have some 10 inside. 
0001e4 f400              brsh hexdec2 
                        
          hexdec2:     
0001e5 509a      	subi hex,0x0A 	; Get tens value by subtracting 10
0001e6 9573              inc tens
0001e7 309a              cpi hex,0x0A 	; Repeat until under 10
0001e8 f7e0              brsh hexdec2 
0001e9 0f69              add unit,hex
0001ea 9508              ret
         
         	
Assembly complete with no errors.

⌨️ 快捷键说明

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