亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? calc.asm

?? 51 計算器 protus keil 源碼 圖
?? ASM
?? 第 1 頁 / 共 4 頁
字號:

 
keycodes:	db 	ON,  '7','8','9', '*', '/'
		db	SGN, '4','5','6', '-', MRC
		db	PCT, '1','2','3', 0,   MSUB
		db	SQR, '0','.','=', '+', MADD


;-----------------------------------------------------------------------------------------
; WAITKEY - Wait for a keypress, lift the key and display it on screen.
;-----------------------------------------------------------------------------------------

waitkey:	push DPH			; Preserve DPTR
		push DPL			;

		call initialize			; Initialise the keybuffer and the LCD display screen.
wk_keyscan: 	call keyscan			; Wait for key press
	 	jnz wk_wrchar		        ; Handle a pressed key
 		push DPH			; don't allow DPTR to be changed
		push DPL
		mov DPTR,#10			; Time delay to wait
 		call wtms			; Wait set time
		pop DPL
		pop DPH
		jmp wk_keyscan			; Check again


wk_wrchar:	call keytest			; Test the type of key pressed
		mov R5,opcodeflag
		cjne R5,#0,wk_ophandle		; Test whether key pressed is a digit or an operator.
		
;*DIGIT PRESS*:
		call statuscheck		; Determine whether this is the first digit pressed since an op press. 
		call storedigit			; Store the digit and inc bufferctr along the buffer.
		call bufferoutput		; Output the number to the LCD display.
		jmp wk_keyscan			; loop back to scan for next entry.


;*OPERATOR PRESS*:

wk_ophandle:	call getmode			; Determine at which buffer the DPTR addresses.
		call handleop			; Deal with the operator logic. 
		jmp wk_keyscan			; loop back and start again.

wk_done:	pop DPL				; Restore DPTR
		pop DPH	
		ret


;============================================
;********** KEYPRESS FUNCTIONS **************
;============================================


;-----------------------------------------------------------------------------------------
; KEYSCAN - Function to return current keypad state in A.
;-----------------------------------------------------------------------------------------


keyscan:	push DPH
		push DPL
		
		mov R0,#keyflags 		; R0 addresses the key toggle bytes
		mov R1,#KEY_ROW1		; R1 address the keyboard row address
		mov R2,#4			; R2 counts rows
ksrow:		mov P2,R1			; Set row address to port P2
		nop
		mov A,P1			; Read column data from port P1
		mov R3,#6			; R3 counts keys per row
		anl A,#3Fh
ks0:		rrc A				; Move next bit into carry
		mov R4,A			; R4 preserves the row data
		jc ks1				; Jump if key not pressed
		mov A,@R0			; Test if key already pressed
		mov @R0,#1			; Flag pressed anyway
		jz ksnew			; Jump if key newly pressed
		jmp ks2
ks1:		mov @R0,#0			; Flag key as not pressed
ks2:		inc R0				; Loop for next key in this row
		mov A,R4
		djnz R3,ks0

		mov A,R1			; Jiggle R1 to address next row
		rl A 
		mov R1,A
		djnz R2,ksrow

		clr A				; Return zero - no (new) key press.
		jmp ksend

						
ksnew:		mov DPTR,#keycodes		; We've found a new key since last time:
		mov A,R0			; The key flag address (ordinal) is in R0
		clr C
		subb A,#keyflags
		movc A,@A+DPTR
		mov digitcode,A			; digitcode now holds the ascii value of the key in (in hex)		
ksend:		mov P2,#0FFh
		pop DPL
		pop DPH
		ret


;--------------------------------------------------------------------------------------------------------
; KEYTEST - Function to test which type of key is pressed. digitcode holds the key information.
; 	    The digit range holding ascii 0 -> 9 is 030h -> 039h.
;	    Opcodeflag designated as the flag for *key type*.  
;---------------------------------------------------------------------------------------------------------

keytest:	mov R4,digitcode 	

		cjne R4,#030h,kt_testlower	; Test lower boundary of the *digit range*. carry is set if < 030h
		jmp kt_isdigit			; key is 030h so is a digit
kt_testlower:	jc kt_decimalpt			; Test the carry flag - if set then key is not a digit so goto op tests. 
		cjne R4,#039h,kt_testupper	; Test upper boundary of *digit range*. carry is set if < 039h	
		jmp kt_isdigit			; key is 039h so is digit.
kt_testupper:	jc kt_isdigit			; if carry set then within *digit range* so jump to kt_isdigit
kt_decimalpt:	cjne R4,#2Eh,kt_addtest		; allow decimal points.
		jmp kt_isdigit

kt_addtest:	cjne R4,#02Bh,kt_subtest	; Test the key info against ascii '+'
		mov opcodeflag,#1		; Key is the addition operator.					
		jmp kt_done
kt_subtest:     cjne R4,#02Dh,kt_multest	; Test the key against ascii '-'
		mov opcodeflag,#2		; Key is the subtraction operator.
		jmp kt_done
kt_multest:	cjne R4,#02Ah,kt_divtest	; Test the key against ascii '*'
		mov opcodeflag,#3		; Key is the multiply operator.
		jmp kt_done
kt_divtest:    	cjne R4,#02Fh,kt_cancel		; Test the key against ascii '/'
		mov opcodeflag,#4		; Key is the divide operator.
		jmp kt_done
kt_cancel:	cjne R4,#ON,kt_equals		; Test the key against the assigned value for the cancel button.
		mov opcodeflag,#5		; Key is the Cancel operator
		jmp kt_done
kt_equals:      cjne R4,#03Dh,kt_sign		; Test the key against ascii '='
		mov opcodeflag,#6		; Key is the equals operator.
		jmp kt_done
kt_sign:	cjne R4,#SGN,kt_mrc		; Test the key against ascii '=' 
		mov opcodeflag,#7               ; Key is the Sign operator.    
		jmp kt_done
kt_mrc:		cjne R4,#MRC,kt_mplus		; Test the key against ascii '=' 
		mov opcodeflag,#8               ; Key is the MRC operator.    
		jmp kt_done
kt_mplus:	cjne R4,#MADD,kt_msub		; Test the key against ascii '=' 
		mov opcodeflag,#9               ; Key is the M+ operator.    
		jmp kt_done
kt_msub:	cjne R4,#MSUB,kt_pcnt		; Test the key against ascii '=' 
		mov opcodeflag,#10              ; Key is the M- operator.    
		jmp kt_done
kt_pcnt:	cjne R4,#PCT,kt_sqr		; Test the key against ascii '=' 
		mov opcodeflag,#11              ; Key is the Percentage operator.    
		jmp kt_done
kt_sqr:		cjne R4,#SQR,kt_done
		mov opcodeflag,#12
		jmp kt_done
kt_isdigit:	mov opcodeflag,#0		; Key is a digit.
		jmp kt_done
kt_done:	ret


						
;======================================================
;************* OPERATOR FUNCTIONS *********************
;======================================================

;---------------------------------------------------------------------------------
;HANDLEOP - Subroutine to test whether the operator is arithmetic or not
;	    and to call the appropriate function handlers.
; 	    If opcodeflag < =4 then arithmetic op else functional op.
;---------------------------------------------------------------------------------
handleop:       clr c				; Clear the carry flag before a cjne instruction
		mov A,opcodeflag
		cjne A,#4,ho_testcarry		; Test operator against 4	
		jmp ho_arithmcall		; if 4 then arithmetic so jump

ho_testcarry:	jc ho_arithmcall		; if less than 4 then arithmetic 
      		call functionops		; otherwise call function ops.
		mov arithopflag,#00h		; If a functional op then clear arithopflag
		jmp ho_done	

ho_arithmcall:  call arithmeticop
ho_done:	ret


;=========================================
;********* ARITHMETIC OPERATORS **********
;=========================================


;---------------------------------------------------------------------------------
;ARITHMETICOP - Subroutine to handle the operator logic for arithmetic operations
;	        *opcodehex* is stored, *oldopcode* is retrieved.
;---------------------------------------------------------------------------------

arithmeticop:	push DPH			; Preserve the Datapointer.
		push DPL
		mov mode,#1			; DPTR addresses the Keybuffer.
		call getmode			
		
		clr c
		mov R5,arithopflag		; Test for consecutive Arithmetic Operator presses
		cjne R5,#1,ao_equalscheck	; If consecutive just store the op.
		jmp ao_store

ao_equalscheck:	clr c
		mov R5,equalsflag		; If *equ* - *arithmetic op* just store the op
		cjne R5,#1,ao_percentcheck	; The equals operation stores the result.
		jmp ao_store

ao_percentcheck:clr c
		mov R5,pctopflag     		; If *pct* - *arithmetic op* just store the op
                cjne R5,#1,ao_statuscheck         ; The percent operation stores the result.     
		jmp ao_store           

ao_statuscheck:	mov R5,status
		cjne R5,#1,ao_normalinput	; Test for *MRC*  - *aritmetic op* sequence
		mov mode,#1			 	
		mov R5,memcounter		; Memcounter holds the length of the number in the Memorybuffer.
		mov bufferctr,R5
		mov digitcode,#0		; Terminate the number.
		call storedigit
		mov mode,#1
		call inputnum			; Input the number.
		mov copyfrom,#1				 
		mov copyto,#3	
		call buffercopy			; Copy the number into the oldnumbuffer.
		jmp ao_store

ao_normalinput:	mov mode,#1			; Test for *digit* - *arithmetic op* sequence
		mov digitcode,#0		 
		call storedigit			; Terminate the number.
		mov mode,#1
		call inputnum			; Input the number.
		mov copyfrom,#1				 
		mov copyto,#3	
		call buffercopy			; Copy the number.

ao_countcheck:	inc opcounter			; opcounter holds the number of operations.
		mov R5,opcounter
		cjne R5,#1,ao_retrieve
		jmp ao_store			; if this is first op nothing to retrieve/output so goto ao_store

ao_retrieve:	mov mode,#1
		call getmode
		call retrieveop			; retrieve the op, execute the opereration 
						; and output the result to the Keybuffer and to the LCD display.
		mov mode,#1
		call inputnum			; Put the result back on the stack.
ao_store:   	call storeop			; store the op type in *opcodehex*

ao_setflags:	mov memopflag,#00h		; Clear/Set the appropriate flags.
		mov equalsflag,#00h
		mov pctopflag,#00h
		mov arithopflag,#01h		
		
ao_done:	mov status,#01h			; set status to indicate that an operator has been pressed.
		call resetsign
		pop DPL
		pop DPH
		ret

;---------------------------------------------------------------------------------
;STOREOP- Subroutine to store the operator. We store *opcodehex*. 
;---------------------------------------------------------------------------------

storeop:	mov R5,opcodeflag	
so_addition:	cjne R5,#1,so_subtract		; If Addition assign code		
		mov opcodehex,#02Bh
so_subtract:	cjne R5,#2,so_multiply		; If Subtraction assign code
		mov opcodehex,#02Dh
so_multiply:	cjne R5,#3,so_divide		; If Multiplication assign code
		mov opcodehex,#02Ah
so_divide:	cjne R5,#4,so_done		; If Division assign code
		mov opcodehex,#02Fh

so_done:	mov A,opcodehex			; Moves the op type into *oldopcode*.
		mov oldopcode,A			; This means on next op press oldopcode is the
						; old code and opcodehex is the new code.       
		ret	

;---------------------------------------------------------------------------------
;RETRIEVEOP - Subroutine to retrieve the operator. We retrieve *oldopcode*.
;---------------------------------------------------------------------------------

retrieveop:	mov R7,oldopcode		; use R7 locally here for the cjne
		clr A
		mov bufferctr,#00h
ro_addition:	cjne R7,#02Bh,ro_subtract	; Test for addition
		call floating_add		; Perform the operation
		call errorcheck			; Check for errors
		jmp ro_output
ro_subtract:	cjne R7,#02Dh,ro_multiply	; Test for subtraction
		call floating_sub		; Perform the operation
		call errorcheck                 ; Check for errors     
		jmp ro_output
ro_multiply:	cjne R7,#02Ah,ro_divide		; Test for multiplication
		call floating_mul		; Perform the operation
		call errorcheck                 ; Check for errors     
		jmp ro_output
ro_divide:	cjne R7,#02Fh,ro_output		; Test for division
		call floating_div		; Perform the operation
		call errorcheck                 ; Check for errors     
		jmp ro_output

ro_output:	mov R5,errorflag
		cjne R5,#0,ro_clear		; Test for errors.
		mov mode,#1			; No error so output result.
		call getmode
		call bufferclear
		mov bufferctr,#00h
		call floating_point_output	; output result both to LCD and to keybuffer.
		call bufferoutput
		jmp ro_done

ro_clear:	mov status,#1			; If an error occurs we clear everything 
		call cancelop			; ready to start again.
ro_done:	ret	



;===================================
;***** FUNCTION OPERATORS **********
;===================================


;---------------------------------------------------------------------------------
;FUNCTIONOPS - Subroutine to handle the non arithmetic operations.
; 	       Determine which functional op is pressed and the call the appropriate subroutine.	
;---------------------------------------------------------------------------------

functionops: 	mov R5,opcodeflag
fo_cancel:	cjne R5,#5,fo_equal
		call cancelop
		jmp fo_done
fo_equal:	cjne R5,#6,fo_signop
		call equalop
		jmp fo_done	
fo_signop:	cjne R5,#7,fo_mrc
		call signop
		jmp fo_done
fo_mrc:		cjne R5,#8,fo_memplus
		call memrecall
		jmp fo_done
fo_memplus:	cjne R5,#9,fo_memsub
		call memplus
fo_memsub:	cjne R5,#10,fo_pcnt
		call memsub		
fo_pcnt:	cjne R5,#11,fo_sqr
		call percentop
fo_sqr:		cjne R5,#12,fo_done
		call banner
		call cancelop
fo_done:	ret

;---------------------------------------------------------------------------------
;CANCELOP - Subroutine to handle the cancel operation.
;---------------------------------------------------------------------------------

cancelop:	push DPH			; Preserve the Datapointer. 
	 	push DPL
		
		mov R5,status			; Test for full or partial clear.
		cjne R5,#0,co_totalclear	

co_partclear:	mov mode,#1			; Partial Clear - Lose num2 and display num1
		call getmode			; This is Sequence:*num1*-*arithop*-*num2*-*cancel*
		call clearscreen		; Scrap the second number ( isn't on the stack here )  
		mov bufferctr,#00h		; Clear before FPO so we know the *size* of the resulting number.
		mov mode,#1
		call getmode		
		call floating_point_output	; Output the first number to the Keybuffer.	
		call bufferoutput		; Output the first number to the LCD Display.
		call inputnum			; Put the first number back on the stack.
		jmp co_setflags
	

co_totalclear:	mov mode,#1			; Total Clear  - Clear the stack and the Keybuffer.
		call getmode
		call floating_point_output	; Output the contents of the stack.	
		call clearscreen		; Clear the screen.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产一区二区在线观看| 久久成人免费电影| 国产成人综合网站| 2欧美一区二区三区在线观看视频| 蜜桃精品视频在线| 久久精品欧美日韩精品 | 99re在线视频这里只有精品| 国产精品第五页| 欧美午夜一区二区| 男人的天堂久久精品| 日韩免费一区二区三区在线播放| 韩国v欧美v亚洲v日本v| 久久久精品免费观看| 99久久免费精品高清特色大片| 国产精品一二三四五| 亚洲国产综合在线| 这里只有精品99re| 国产河南妇女毛片精品久久久 | 2019国产精品| 国产三级三级三级精品8ⅰ区| 国产女主播视频一区二区| 欧美日韩三级一区| 91网上在线视频| 国产综合久久久久久久久久久久| 精品在线免费视频| 午夜视频在线观看一区二区三区| 国产色产综合色产在线视频 | 欧美日韩三级视频| 日韩写真欧美这视频| 色94色欧美sute亚洲线路一ni| 蜜桃av一区二区在线观看| 麻豆精品视频在线观看免费| 国产成人一区二区精品非洲| 91视频.com| 欧美一级二级三级乱码| 亚洲国产成人在线| 26uuu久久综合| 亚洲激情自拍视频| 国产欧美一区二区精品性色超碰| 亚洲欧美日韩一区| 国产精品情趣视频| 亚洲国产精品成人综合| 亚洲一区二区视频| 亚洲电影视频在线| 亚洲国产aⅴ天堂久久| 国产一区二区三区四| 国产美女主播视频一区| 欧美日韩国产免费| 这里只有精品电影| 亚洲色欲色欲www在线观看| 久久久亚洲高清| 亚洲一卡二卡三卡四卡| 国产伦精品一区二区三区免费迷| 欧美午夜影院一区| 一区二区中文视频| 一区二区三区在线免费播放| 亚洲第一搞黄网站| 一本大道av一区二区在线播放| 99精品国产一区二区三区不卡| 日韩精品中文字幕在线一区| 一区二区三区欧美日韩| 成人h动漫精品| 色av成人天堂桃色av| 国产精品色噜噜| 国产精品一区免费在线观看| 日韩欧美在线综合网| 亚洲大片在线观看| 欧美日韩一区二区在线视频| 亚洲视频免费看| 成人高清视频在线| 2020日本不卡一区二区视频| 日韩国产在线观看一区| 亚洲综合色视频| 99久久99久久综合| 日韩一区在线免费观看| www.亚洲国产| 日韩一二三四区| 美腿丝袜亚洲三区| 久久伊99综合婷婷久久伊| 久久福利资源站| 久久久国产午夜精品| 激情图区综合网| 久久伊人中文字幕| 国产成人av在线影院| 国产精品久久精品日日| 成人毛片视频在线观看| 91精品视频网| 久久精品免费观看| 欧美xxxxx裸体时装秀| **网站欧美大片在线观看| 国产成人免费在线视频| 中文字幕av不卡| 91在线免费视频观看| 亚洲图片自拍偷拍| 欧美另类高清zo欧美| 亚洲欧洲日韩综合一区二区| 国产91精品欧美| 欧美成人性福生活免费看| 国产在线精品一区二区三区不卡 | 欧美日韩精品欧美日韩精品| 日韩av一区二区三区| 久久久久久毛片| 91在线看国产| 三级欧美在线一区| 久久久久九九视频| 欧美综合亚洲图片综合区| 国产亚洲欧洲一区高清在线观看| 粉嫩av一区二区三区| 亚洲午夜精品17c| 精品动漫一区二区三区在线观看 | 亚洲国产婷婷综合在线精品| 宅男在线国产精品| 成人av网在线| 婷婷中文字幕一区三区| 久久久久久免费网| 欧美日韩高清一区| 国产成人日日夜夜| 日本中文字幕一区二区视频| 久久精品欧美一区二区三区不卡 | 久久久高清一区二区三区| 色久优优欧美色久优优| 精品一区二区免费看| 亚洲精品一二三| 久久久久久久久久久久久女国产乱| 99精品久久只有精品| 韩日av一区二区| 肉肉av福利一精品导航| 一区二区在线观看视频在线观看| 精品国产乱码久久久久久免费 | 日本一区二区免费在线| 欧美日韩在线一区二区| 成人一二三区视频| 久久精品国产99久久6| 亚洲制服丝袜av| 亚洲人成网站精品片在线观看| 精品欧美一区二区在线观看| 欧美男女性生活在线直播观看| 91网页版在线| 成人18视频日本| 成人午夜伦理影院| 国产一区二区网址| 免费欧美高清视频| 日韩国产欧美在线视频| 亚洲国产成人av| 亚洲国产另类av| 亚洲国产日韩一级| 亚洲午夜激情网站| 午夜伦理一区二区| 日韩中文欧美在线| 日本午夜一区二区| 日本美女视频一区二区| 日韩高清在线一区| 麻豆freexxxx性91精品| 麻豆91在线看| 黑人巨大精品欧美一区| 国产主播一区二区| 成人午夜私人影院| 波多野结衣亚洲| 色国产精品一区在线观看| 91丨国产丨九色丨pron| 色综合久久久久综合体| 欧美亚男人的天堂| 亚洲日本va在线观看| 不卡大黄网站免费看| 日本成人超碰在线观看| 蜜臀久久99精品久久久画质超高清 | 久久综合狠狠综合久久综合88 | 亚洲天堂成人在线观看| 亚洲伦理在线精品| 亚洲福利电影网| 免费观看30秒视频久久| 黑人巨大精品欧美一区| 成人午夜免费电影| 欧美性猛片aaaaaaa做受| 69堂国产成人免费视频| 久久久久久久久久久电影| 国产精品污www在线观看| 亚洲三级免费观看| 日韩成人av影视| 国产99久久久久| 色狠狠桃花综合| 日韩一区二区在线观看视频| 国产亚洲精品7777| 一区二区欧美国产| 老司机午夜精品| 色综合视频在线观看| 欧美日韩aaaaa| 中文成人综合网| 亚洲成a人v欧美综合天堂| 韩国精品主播一区二区在线观看| 91麻豆国产福利精品| 在线不卡一区二区| 国产日韩欧美麻豆| 午夜伦欧美伦电影理论片| 国产99久久久国产精品潘金| 欧美伊人久久久久久久久影院| 久久亚洲精华国产精华液 | 欧美挠脚心视频网站| 国产三级精品视频| 亚洲香肠在线观看|