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

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

?? calc.asm

?? 實現簡單的計算器功能,方便又實用,簡單易懂,僅供參考
?? 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一区二区三区免费野_久草精品视频
麻豆精品视频在线观看视频| 亚洲黄色片在线观看| 国产精品灌醉下药二区| 五月天激情小说综合| 成人福利视频在线| 2019国产精品| 日韩高清不卡一区二区| 91美女视频网站| 国产午夜精品一区二区三区嫩草 | 2017欧美狠狠色| 亚洲综合精品久久| 成人国产免费视频| 久久蜜桃一区二区| 日韩成人伦理电影在线观看| 色综合久久久久综合体桃花网| 精品国产乱码久久久久久闺蜜| 亚洲成精国产精品女| 97久久久精品综合88久久| 欧美精品一区二区三区在线播放| 一区二区三区日本| 91视频国产资源| 1区2区3区精品视频| 高清不卡一二三区| 国产日本欧美一区二区| 国产一区美女在线| 日韩欧美成人一区| 麻豆91免费看| 欧美成人vps| 精品一区二区三区久久久| 91精品免费在线观看| 日韩精品亚洲一区| 欧美三级中文字幕| 日产国产高清一区二区三区 | 精品国产乱码久久| 亚洲黄网站在线观看| 色婷婷综合久久久久中文 | 久久久久久久久久久久久夜| 免费在线观看一区二区三区| 欧美高清视频不卡网| 首页国产丝袜综合| 欧美一区二区精品在线| 久久99久久99小草精品免视看| 26uuu另类欧美| 国产91对白在线观看九色| 国产精品久久久久影院老司| 91天堂素人约啪| 一区二区久久久久久| 欧美肥胖老妇做爰| 亚洲v中文字幕| 欧美艳星brazzers| 日韩成人一级片| 久久久www免费人成精品| 高清成人在线观看| 亚洲午夜精品久久久久久久久| 在线精品亚洲一区二区不卡| 午夜激情久久久| 久久精品视频免费观看| 菠萝蜜视频在线观看一区| 一区二区三区中文免费| 日韩一区二区在线观看| 国产·精品毛片| 亚洲va国产va欧美va观看| 精品卡一卡二卡三卡四在线| 成人动漫中文字幕| 偷拍一区二区三区四区| 国产视频一区不卡| 欧美三区在线观看| 粉嫩av亚洲一区二区图片| 一区二区不卡在线播放| 久久这里只精品最新地址| 99re这里只有精品首页| 蜜桃一区二区三区在线观看| 日本一区免费视频| 欧美精品丝袜中出| 成人丝袜18视频在线观看| 午夜久久久久久电影| 国产精品热久久久久夜色精品三区| 在线免费观看一区| 国产不卡免费视频| 奇米888四色在线精品| 亚洲久本草在线中文字幕| 精品av久久707| 欧美日韩国产区一| 成人黄色在线看| 精品一区二区三区在线播放视频| 亚洲精品国产品国语在线app| 久久综合五月天婷婷伊人| 欧美在线看片a免费观看| jlzzjlzz亚洲日本少妇| 狠狠色丁香婷婷综合| 蜜臀久久99精品久久久久宅男| 亚洲视频电影在线| 亚洲国产精品激情在线观看| 日韩精品资源二区在线| 欧美肥妇bbw| 在线视频一区二区三| 91亚洲精品一区二区乱码| 国产福利一区二区三区在线视频| 免费成人av在线| 香蕉av福利精品导航| 亚洲一区在线观看免费 | 午夜精品久久久| 中文字幕永久在线不卡| 久久久无码精品亚洲日韩按摩| 日韩欧美一区二区视频| 欧美日韩国产不卡| 欧美综合视频在线观看| 91污片在线观看| 91视频精品在这里| eeuss鲁一区二区三区| 成人中文字幕合集| 大美女一区二区三区| 不卡在线视频中文字幕| 不卡的av在线播放| voyeur盗摄精品| av激情亚洲男人天堂| 97久久精品人人爽人人爽蜜臀| 成人黄色在线看| 91蜜桃网址入口| 欧美亚洲丝袜传媒另类| 欧美日韩精品欧美日韩精品一| 国内精品不卡在线| 在线影院国内精品| 色噜噜狠狠成人网p站| 97超碰欧美中文字幕| eeuss鲁一区二区三区| 色综合久久88色综合天天| 欧美视频一区二区三区在线观看| 欧美亚洲综合色| 91精品国产综合久久婷婷香蕉 | 一区二区三区在线看| 一区二区高清免费观看影视大全| 亚洲一区二区精品3399| 五月天精品一区二区三区| 久久66热re国产| 床上的激情91.| 在线一区二区三区四区五区| 4438成人网| 国产三级精品视频| 亚洲福利国产精品| 久久精品免费观看| 91丨九色丨蝌蚪丨老版| 欧美另类久久久品| 26uuu国产日韩综合| 亚洲另类在线视频| 久久成人免费网站| 91丝袜美腿高跟国产极品老师| 欧美乱妇一区二区三区不卡视频| 久久久99久久| 亚洲动漫第一页| 国产福利一区二区三区| 色av一区二区| 久久久无码精品亚洲日韩按摩| 亚洲色图第一区| 精品亚洲成a人在线观看| av亚洲精华国产精华| 欧美欧美午夜aⅴ在线观看| 欧美激情一区二区三区| 午夜伦欧美伦电影理论片| www.亚洲免费av| 欧美一区二区精品在线| 日韩毛片在线免费观看| 久久se精品一区二区| 在线观看欧美日本| 国产日韩欧美麻豆| 蓝色福利精品导航| 欧美性大战久久久久久久 | 亚洲国产一区二区a毛片| 国产精品一级二级三级| 欧美日韩成人在线一区| 亚洲欧美一区二区久久 | 色婷婷久久久综合中文字幕 | 国产精品一区二区x88av| 91福利小视频| 国产精品久久夜| 狠狠色狠狠色综合| 91精品国产一区二区三区香蕉| 亚洲天堂av老司机| 成人久久久精品乱码一区二区三区 | 欧美午夜电影网| 国产精品天天看| 国产一区999| 欧美va亚洲va在线观看蝴蝶网| 亚洲成人777| 欧美亚洲尤物久久| 亚洲乱码国产乱码精品精98午夜 | 最新国产の精品合集bt伙计| 国产激情一区二区三区四区| 欧美一区二区三区在线看| 亚洲尤物在线视频观看| 欧美亚洲一区二区在线观看| 亚洲精品久久7777| 91免费小视频| 亚洲女与黑人做爰| 日本丶国产丶欧美色综合| 亚洲精品中文字幕在线观看| 91在线你懂得| 亚洲综合免费观看高清完整版 | 久久丝袜美腿综合| 国产精品一区2区|